SingleByteToUTF8 function
Converts a string with single-byte values to UTF-8 using a character translation array.
Declaration
function SingleByteToUTF8(const s: string;
const Table: TCharToUTF8Table): stringArguments
s | String with the single-byte values converted in the routine. |
Table | Table with Character to PChar mappings for the converted value. |
Function result
String with the UTF-8-encoded value, or an empty string.
Description
s is the string, in its single-byte encoding, with the character values converted in the routine.
Table is a TCharToUTF8Table type and contains an array with the multi-byte values for each of the character using the UTF-8 encoding. The array has 256 elements representing #0 and each of the decimal values in the single byte character set, and may contain 1-4 byte values as needed for the UTF-8 encoding.
SingleByteToUTF8 iterates over the character values in s, and converts each single-byte character to the multi-byte value at the corresponding ordinal position in Table. If s is an empty string (''), the return value is also an empty string.
The return value is cast to a RawByteString type, and its code page is set to CP_UTF8 (65001).
See also
- TCharToUTF8Table
- ArrayISO_8859_1ToUTF8
- ArrayISO_8859_2ToUTF8
- ArrayISO_8859_14ToUTF8
- ArrayISO_8859_15ToUTF8
- ArrayCP1250ToUTF8
- ArrayCP1251ToUTF8
- ArrayCP1252ToUTF8
- ArrayCP1253ToUTF8
- ArrayCP1254ToUTF8
- ArrayCP1255ToUTF8
- ArrayCP1255ToUTF8
- ArrayCP1257ToUTF8
- ArrayCP437ToUTF8
- ArrayCP850ToUTF8
- ArrayCP866ToUTF8
- ArrayKOI8RToUTF8
- ArrayKOI8UToUTF8
- ArrayMacintoshToUTF8
An experiment, built from development snapshots. Not the official Free Pascal or Lazarus documentation.
