RAD Studio VCL Reference
SysUtils.ByteToCharLen Function

Returns the number of characters fully contained in the first MaxLen bytes of a string.

function ByteToCharLen(const S: AnsiString; MaxLen: Integer): Integer; overload;
function ByteToCharLen(const S: UnicodeString; MaxLen: Integer): Integer; overload;
int ByteToCharLen(const AnsiString S, int MaxLen);
int ByteToCharLen(const UnicodeString S, int MaxLen);

Call ByteToCharLen to determine the number of characters represented by a portion of a string. ByteToCharLen counts characters until it reaches MaxLen bytes or the end of the string, whichever comes first. 

When working with multi-byte character systems (MBCS), the value returned by ByteToCharLen may be less than MaxLen or the length of the string.

Note: ByteToCharLen will count a partial character if it appears as the last of the first MaxLen bytes.


Copyright(C) 2009 Embarcadero Technologies, Inc. All Rights Reserved.
What do you think about this topic? Send feedback!