SysUtils.ByteToCharIndex
Contents |
Delphi Information
From SysUtils.pas
function ByteToCharIndex(const S: AnsiString; Index: Integer): Integer; overload; function ByteToCharIndex(const S: string; Index: Integer): Integer; overload;
Unit: SysUtils
Type: function
Visibility: public
C++ Information
From SysUtils.hpp
int __fastcall ByteToCharIndex(System::AnsiStringT<0> S, int Index);
Unit: SysUtils
Type: function
Description
Returns the position of the character that contains a specified byte in a string.
Call ByteToCharIndex to determine which character contains a particular byte in a string, where 1 specifies the first byte, 2 specifies the second byte, and so on. If the Index parameter specifies a byte that is not in the AnsiString (Index < 0 or Index > Length(S)), ByteToCharIndex returns 0.
If the system does not use a multi-byte character system (MBCS), ByteToCharIndex simply returns the value of Index, because there is a 1:1 correspondence between bytes and characters. Otherwise, ByteToCharIndex returns the position of the character, where 1 specifies the first character, 2 specifies the second character, and so on.
For example, if an AnsiString contains two characters, a single-byte character followed by a double-byte character, then ByteToCharIndex returns 1 when Index is 1, it returns 2 when Index is 2 or 3, and it returns 0 for any other value of Index.