System.SysUtils.ByteToCharIndex
Delphi
function ByteToCharIndex(const S: UnicodeString; Index: Integer): Integer;
function ByteToCharIndex(const S: AnsiString; Index: Integer): Integer;
C++
extern DELPHI_PACKAGE int __fastcall ByteToCharIndex _DEPRECATED_ATTRIBUTE1("Use ElementToCharIndex.") (const System::UnicodeString S, int Index)/* overload */;
Properties
Type | Visibility | Source | Unit | Parent |
---|---|---|---|---|
function | public | System.SysUtils.pas System.SysUtils.hpp |
System.SysUtils | System.SysUtils |
Description
Warning: ByteToCharIndex is deprecated. Please use ElementToCharIndex.
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.