ConvertEncodingToUTF8 function
Converts the specified string value to the UTF-8 encoding.
Declaration
function ConvertEncodingToUTF8(const s: string;
const FromEncoding: string;
out Encoded: Boolean): stringDescription
ConvertEncodingToUTF8 converts the encoding for a string value from the specified encoding to UTF-8. The s argument contains the string value converted in the routine.
FromEncoding is a String value with the name for the existing encoding is s. It is normalized in the routine to remove hyphen characters in the encoding name. The value corresponds to the encoding name constants defined in the unit, and is used to determine which routine is called to perform the encoding conversion.
For example, the following is a sample of the encoding names and their corresponding conversion routines:
- EncodingUTF8BOM ('utf8bom')
- UTF8BOMToUTF8
- EncodingCPIso1 ('iso88591')
- ISO_8859_1ToUTF8
- EncodingCPIso2 ('iso88592')
- ISO_8859_2ToUTF8
- EncodingCPIso3 ('iso88593')
- ISO_8859_3ToUTF8
- EncodingCPIso4 ('iso88594')
- ISO_8859_4ToUTF8
- EncodingCPIso5 ('iso88595')
- ISO_8859_5ToUTF8
- EncodingCPIso7 ('iso88597')
- ISO_8859_7ToUTF8
- EncodingCPIso9 ('iso88599')
- ISO_8859_9ToUTF8
- EncodingCPIso10 ('iso885910')
- ISO_8859_9ToUTF10
- EncodingCPIso13 ('iso885913')
- ISO_8859_9ToUTF13
- EncodingCPIso14 ('iso885914')
- ISO_8859_14ToUTF8
- EncodingCPIso15 ('iso885915')
- ISO_8859_15ToUTF8
- EncodingCPIso16 ('iso885916')
- ISO_8859_16ToUTF8
- EncodingCP1250 ('cp1250')
- CP1250ToUTF8
- EncodingCP1251 ('cp1251')
- CP1251ToUTF8
- EncodingCP1252 ('cp1252')
- CP1252ToUTF8
- EncodingCP1253 ('cp1253')
- CP1253ToUTF8
- EncodingCP1254 ('cp1254')
- CP1254ToUTF8
- EncodingCP1255 ('cp1255')
- CP1255ToUTF8
- EncodingCP1256 ('cp1256')
- CP1256ToUTF8
- EncodingCP1257 ('cp1257')
- CP1257ToUTF8
- EncodingCP1258 ('cp1258')
- CP1258ToUTF8
- EncodingCP437 ('cp437')
- CP437ToUTF8
- EncodingCP850 ('cp850')
- CP850ToUTF8
- EncodingCP852 ('cp852')
- CP852ToUTF8
- EncodingCP854 ('cp865')
- CP865ToUTF8
- EncodingCP866 ('cp866')
- CP866ToUTF8
- EncodingCP874 ('cp874')
- CP874ToUTF8
- EncodingCP932 ('cp932')
- CP932TOUTF8
- EncodingCP936 ('cp936')
- CP936TOUTF8
- EncodingCP949 ('cp949')
- CP949TOUTF8
- EncodingCP950 ('cp950')
- CP950TOUTF8
- EncodingCPKOI8R ('koi8r')
- KOI8RToUTF8
- EncodingCPKOI8U ('koi8u')
- KOI8UToUTF8
- EncodingCPKOI8RU ('koi8ru')
- KOI8RUToUTF8
- EncodingCPMac ('macinstosh')
- MacintoshToUTF8
- EncodingUCS2LE ('ucs2le')
- UCS2LEToUTF8
- EncodingUCS2BE ('ucs2be')
- UCS2BEToUTF8
- EncodingAnsi ('ansi') or the default text encoding for the platform
- ConvertAnsiToUTF8
Encoded is a Boolean output parameter which indicates if a routine was found to perform the requested conversion. Its value is False when a conversion routine was not found for the source encoding in FromEncoding.
ConvertEncodingToUTF8 is used in the implementation of the ConvertEncoding function.
See also
An experiment, built from Lazarus main 2dfa93c66e of 10-22-2026. Not the official Lazarus documentation.
