System.AnsiStrings.CharToElementIndex
Delphi
function CharToElementIndex(const S: AnsiString; Index: Integer): Integer;
C++
extern DELPHI_PACKAGE int __fastcall CharToElementIndex(const System::AnsiString S, int Index)/* overload */;
Properties
Type | Visibility | Source | Unit | Parent |
---|---|---|---|---|
function | public | System.AnsiStrings.pas System.AnsiStrings.hpp |
System.AnsiStrings | System.AnsiStrings |
Description
Returns the 1-based index of the first element of a specified character in a string.
Call CharToElementIndex to obtain the 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. CharToElementIndex 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, CharToElementIndex returns the offset of the first byte.
If the system is not using a multi-byte character system (MBCS), CharToElementIndex returns the value of Index, because there is a 1:1 correspondence between bytes and characters.