System.AnsiStringBase.SetLength

From RAD Studio API Documentation
Jump to: navigation, search

C++

AnsiStringBase&  SetLength(int newLength, int codePage);

Properties

Type Visibility Source Unit Parent
function public dstring.h System AnsiStringBase

Description

Changes the length of AnsiStringBase.

SetLength changes the string's length to newLength, truncating if necessary.

SetLength reallocates the underlying array of characters that stores the value of AnsiStringBase. Existing characters in the string are preserved, but the content of newly allocated space is undefined. If there is not enough memory available to reallocate AnsiStringBase, an EOutOfMemory exception is thrown. Following a call to SetLength, the AnsiStringBase is guaranteed not to be a shared reference.

SetLength returns the modified AnsiStringBase object.