[Overview][Constants][Types][Procedures and functions][Variables][Index] Reference for unit 'LConvEncoding' (#lazutils)

ConvertEncodingToUTF8

Converts the specified string value to the UTF-8 encoding.

Declaration

Source position: lconvencoding.pas line 112

function ConvertEncodingToUTF8(

  const s: string;

  const FromEncoding: string;

  out Encoded: Boolean

):string;

Arguments

s

  

String with the encoded value converted to UTF-8.

FromEncoding

  

Encoding name for the value in s.

Encoded

  

True if the result contains a multi-byte encoded value. Always True for conversions to UTF-8.

Function result

Value for the specified string after encoding conversion.

Description

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.

Remark: Conversions to the UTF-8 encoding will always set the code page for the converted value to CP_UTF8 (65001). In other words, the SetTargetCodePage argument to the ConvertEncoding() function is ignored for conversions to UTF-8.

See also

ConvertEncoding

  

Converts the specified value from its source encoding to a target encoding using an optional code page.

ConvertEncodingFromUTF8

  

Converts the encoded value from UTF-8 to the encoding with the specified name.

ConvertAnsiToUTF8

  

Contains the routine used to convert an ANSI string value to UTF-8 encoding.

NormalizeEncoding

  

Converts the specified encoding name to lowercase and removes '-' characters.

GetDefaultTextEncoding

  

Gets the name for the default text encoding used on the platform or operating system.


Version 3.2 Generated 2024-02-25 Home