Sign in Join
FPDoc Onlineexperiment

UTF8ToUCS2LE function

In unit LConvEncoding

Converts a UTF-8-encoded value to UCS 2-byte Little Endian encoding.

Declaration

pascal
function UTF8ToUCS2LE(const s: string): string

Description

UTF8ToUCS2LE converts the string value in s from its multi-byte variable length UTF-8 encoding to the fixed length 16-bit character set used in the UCS2 LE (Little Endian) encoding. UTF8ToUCS2LE iterates over each of the UTF-8 codepoints in s, and calls NtoLE to convert the Unicode character value to the Least Significant byte order used in the encoding. Unicode characters with a value $FFFF or greater are ignored in the conversion.

No actions are performed in the routine when s contains an empty string (''), and the return value is set to an empty string as well.

UTF8ToUCS2LE does not include a byte order mark (BOM) in the UCS2-encoded output.

An experiment, built from Lazarus main 2dfa93c66e of 10-22-2026. Not the official Lazarus documentation.