System.UTF8ToString

From RAD Studio API Documentation
Jump to: navigation, search

Delphi

function UTF8ToString(const S: _RawByteStr): string;
function UTF8ToString(const S: _ShortStr): string;
function UTF8ToString(const S: _PAnsiChr): string;
function UTF8ToString(const S: array of Byte): string; overload;

C++

extern DELPHI_PACKAGE UnicodeString __fastcall UTF8ToString(const RawByteString S)/* overload */;

Properties

Type Visibility Source Unit Parent
function public
System.pas
System.hpp
System System

Description

Converts a UTF-8 encoded string to a string.

Call UTF8ToString to convert a UTF-8 encoded string to a string. S is a string or an array of UTF-8 encoded characters that can have the following formats:

The result of the function is the corresponding decoded string value.

Attention: The UTF8ToString(const S: _PAnsiChr) method was removed. Code invoking UTF8ToString with a static array of AnsiChar works as expected. But code invoking UTF8ToString with a dynamic array of AnsiChar no longer compiles. For dynamic arrays you can cast the array to PAnsiChar, as shown below, or use the UTF8ArrayToString.
var
  Buffer: array of AnsiChar; // Or TArray<AnsiChar>
begin
  ...
  UTF8ToString(PAnsiChar(Buffer));

See Also