RAD Studio VCL Reference
ContentsIndex
PreviousUpNext
System.Utf8ToUnicode Function

Converts a string of UTF-8 characters to a Unicode string.

Pascal
function Utf8ToUnicode(Dest: PWideChar; Source: PAnsiChar; MaxChars: Integer): Integer; overload; deprecated;
function Utf8ToUnicode(Dest: PWideChar; MaxDestChars: Cardinal; Source: PAnsiChar; SourceBytes: Cardinal): Cardinal; overload;
C++
int Utf8ToUnicode(PWideChar Dest, PAnsiChar Source, int MaxChars);
unsigned Utf8ToUnicode(PWideChar Dest, unsigned MaxDestChars, PAnsiChar Source, unsigned SourceBytes);

Call Utf8ToUnicode to convert a UTF-8 string to Unicode. Use the second syntax. The deprecated syntax is provided for backward compatibility only. 

Dest receives the resulting null-terminated array of Unicode characters. 

MaxDestChars or MaxChars indicates the maximum number of Unicode characters that the buffer specified by Dest can hold, not counting the null terminator.  

Source is an array of UTF-8 characters. 

SourceBytes is the number of bytes in Source. If SourceBytes is not specified, Source must be null-terminated. 

Utf8ToUnicode returns the number of characters written to Dest. 

In case of errors, the Utf8ToUnicode ... : Cardinal variant returns Cardinal(-1) == $FFFFFFFF and the Utf8ToUnicode ... : Integer returns -1

 

Copyright(C) 2009 Embarcadero Technologies, Inc. All Rights Reserved.
What do you think about this topic? Send feedback!