Skip to content

TCharacter.ConvertToUtf32

Convert a UTF16 character to a UTF32 character

Declaration

Source position: character.pas line 86

public 
  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;

Description

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

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. 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

Name Description
EArgumentException Invalid argument passed to a function
EArgumentOutOfRangeException Argument out of valid range passed to a function
TCharacter.ConvertFromUtf32 Convert a UTF32 character to UnicodeString