
USING task.HexUtils.

MESSAGE SESSION:CPINTERNAL.

DEFINE VARIABLE rawData AS RAW NO-UNDO.
DEFINE VARIABLE chData AS CHARACTER NO-UNDO.
DEFINE VARIABLE intEncoding AS INTEGER NO-UNDO.
DEFINE VARIABLE hexEncoding AS CHARACTER NO-UNDO.
DEFINE VARIABLE intCodePoint AS INTEGER NO-UNDO.
DEFINE VARIABLE hexCodePoint AS CHARACTER NO-UNDO.

chData = CHR(128, "UTF-8", "1252").
PUT-STRING(rawData, 1) = chData.
MESSAGE "# of chars:" LENGTH(chData).
MESSAGE "# of bytes before truncation:" LENGTH(rawData).

// Truncate the length to avoid adding the null terminator 
// This avoids an extra left shift when computing the decimal representation
LENGTH(rawData) = LENGTH(chData, "RAW").

intEncoding = HexUtils:rawToInt(rawData).
hexEncoding = HexUtils:rawToHex(rawData).

MESSAGE "# of bytes after truncation:" LENGTH(chData, "RAW").
MESSAGE "Hex Encoding:" hexEncoding.
MESSAGE "Decimal Encoding:" intEncoding.

