Expand description
UTF-8 encoding for TeX characters.
TeX characters are code points 0–0x10FFFF, including surrogates, which LuaTeX encodes like any other value (a superset of standard UTF-8, as in WTF-8). Strings of TeX characters are therefore kept as byte vectors.
Constants§
- RAW_
BYTE - Marks, in a decoded input line, a byte that does not start a valid
UTF-8 sequence:
RAW_BYTE | b. The tokenizer reports it (LuaTeX’s “String contains an invalid utf-8 sequence”) and error contexts show the byte itself.
Functions§
- chars
- Decodes a whole byte string into characters.
- chars_
marking_ invalid - Decodes an input line like
chars, but marks the bytes of invalid sequences withRAW_BYTE. - decode
- Decodes the character starting at
bytes[i], returning it and its length. Malformed sequences decode as their first byte (length 1), which is how LuaTeX treats invalid input bytes. - encode
- The encoding of a single character.
- is_raw
- Whether
cis aRAW_BYTEmarker. - len
- Number of bytes in the encoding of
c. - push
- Appends the encoding of
ctoout. - push_
entry - Appends the bytes of input-line entry
ctoout: aRAW_BYTEmarker stands for its byte, any other value for its encoding. - single_
char - If
bytesencodes exactly one character, returns it.