Sign in Join
FPDoc Onlineexperiment

TCharacter.ConvertToUtf32 function

Member of TCharacterpublicIn unit Character

Convert a UTF16 character to a UTF32 character.

Declaration

pascal
class function ConvertToUtf32(const AString: UnicodeString; 
 AIndex: Integer): UCS4Char; overload
 ; static
class function ConvertToUtf32(const AString: UnicodeString; 
 AIndex: Integer; out ACharLength: Integer)
: UCS4Char; overload; static
class function ConvertToUtf32(const AHighSurrogate: UnicodeChar; 
 const ALowSurrogate: UnicodeChar)
: UCS4Char; overload; static

Arguments

AString

String containing the character to encode.

AIndex

Index at which the character to encode is located.

ACharLength

Character length (in UTF16 characters).

AHighSurrogate

The high pair of the surrogate.

ALowSurrogate

The low pair of the surrogate.

Function result

The Unicode character in UTF32 format.

Description

TCharacter.ConvertToUtf32 converts a UTF16-encoded Unicode character to a Unicode32 character. This is the opposite of ConvertFromUtf32. The function exists in several overloaded versions, to be able to present the Unicode character in one of 2 ways:

  1. As a position AIndex (in unicodechar units) in a string AString to a Unicode32 character. The source is a string, since multiple UTF16 characters can be needed to encode a single UTF32 character. In this form, Optionally, the character length (1 or 2) can be returned in ACharLength.
  2. As 2 UTF16 Unicode characters, representing the high and low surrogate pairs: AHighSurrogate and ALowSurrogate.

Errors

If AIndex is not a valid character index in the string AString, an EArgumentOutOfRangeException exception is raised. If the character at that position is not complete, an EArgumentException exception is raised.

See also

An experiment, built from development snapshots. Not the official Free Pascal or Lazarus documentation.