From RAD Studio API Documentation
Jump to: navigation, search


function Length(S: <string or dynamic array>): Integer;


Type Visibility Source Unit Parent
function public System.pas System System


Returns the number of characters in a string or of elements in an array.

In Delphi code, Length returns the number of characters actually used in the string or the number of elements in the array. In C++ code, use the method of the same name on the AnsiString or DynamicArray class.

S is a string-valued or array-valued expression.

For single-byte and multibyte strings, Length returns the number of bytes used by the string. Example for UTF-8:

Writeln(Length(Utf8String('1¢'))); // displays 3

For Unicode (WideString) strings, Length returns the number of bytes divided by two.

See Also

Code Examples