System.SysUtils.CharToByteIndex
Delphi
function CharToByteIndex(const S: UnicodeString; Index: Integer): Integer;
function CharToByteIndex(const S: AnsiString; Index: Integer): Integer;
C++
extern DELPHI_PACKAGE int __fastcall CharToByteIndex _DEPRECATED_ATTRIBUTE1("Use CharToElementIndex.") (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: CharToByteIndex is deprecated. Please use CharToElementIndex.
Returns the 1-based index of the first byte of a specified character in a string.
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.