In Firemonkey on mobile (so without any ansiString/UTF8String support) how to convert a unicode String
to utf8 bytes array (Tbytes)
?
This is not related to FireMonkey in fact. Text encoding support is provided at the RTL level. You use the TEncoding
class.
To obtain UTF-8 bytes from a string, do:
var
bytes: TBytes;
str: string;
....
str := ...;
bytes := TEncoding.UTF8.GetBytes(str);
In the reverse direction:
str := TEncoding.UTF8.GetString(bytes);