System.SysUtils.ByteToCharIndex

De RAD Studio API Documentation
Aller à : navigation, rechercher

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 */;

Propriétés

Type Visibilité  Source Unité  Parent
function public
System.SysUtils.pas
System.SysUtils.hpp
System.SysUtils System.SysUtils

Description

Avertissement : ByteToCharIndex est obsolète. Veuillez utiliser ElementToCharIndex.

Renvoie la position du caractère contenant un octet spécifié dans une chaîne.

Appelez ByteToCharIndex pour déterminer quel caractère contient un octet précis dans une chaîne, où 1 spécifie le premier octet. Si le paramètre Index spécifie un octet non présent dans la chaîne, (Index < 0 ou Index > Length(S)), ByteToCharIndex renvoie 0.

Si le système n'utilise pas un jeu de caractères codés sur plusieurs octets (MBCS), ByteToCharIndex renvoie la valeur de Index, en raison de la correspondance "1:1" entre les octets et les caractères. Sinon, ByteToCharIndex renvoie la position du caractère, avec 1 spécifiant le premier caractère, 2 le second, etc.

Par exemple, si une chaîne contient deux caractères, un caractère d'un octet suivi d'un caractère double octet, ByteToCharIndex renvoie alors 1 quand Index est à 1, renvoie 2 quand Index est à 2 ou 3, et renvoie 0 pour toute autre valeur de Index.

Voir aussi