RAD Studio VCL Reference
ContentsIndex
PreviousUpNext
SysUtils.CharToByteIndex Function

Returns the 1-based index of the first byte of a specified character in a string.

Pascal
function CharToByteIndex(const S: string; Index: Integer): Integer;
C++
int CharToByteIndex(const AnsiString S, int Index);

SysUtils

Call CharToByteIndex to obtain the byte offset for the character at a specified position in the string S, where 1 specifies the first character, 2 specifies the second character, and so on. CharToByteIndex returns zero if Index is out of range (Index <= 0 or S contains fewer than Index characters). If the Index parameter indicates a double-byte character, CharToByteIndex returns the offset of the first byte. 

If the system is not using a multi-byte character system (MBCS), CharToByteIndex returns the value of Index, because there is a 1:1 correspondence between bytes and characters. 

 

Copyright(C) 2008 CodeGear(TM). All Rights Reserved.
What do you think about this topic? Send feedback!