l0_string_escape namespace

Classes

class EscapeDecodeError
Raised when an invalid escape sequence is encountered during decoding.

Functions

auto decode_l0_string_token(str text) -> bytes
Decode an L0 string literal payload to raw bytes.
auto encode_c_string_bytes(bytes data) -> str
Encode raw bytes into a C-safe string literal body.

Variables

str _HEX_CHARS
str _OCT_CHARS
_TRIGRAPH_THIRD_BYTES
dict _SIMPLE_ESCAPES

Function documentation

bytes l0_string_escape::decode_l0_string_token(str text)

Decode an L0 string literal payload to raw bytes.

Parameters
text The string literal content (without surrounding quotes).
Returns The decoded bytes.
Exceptions
EscapeDecodeError If a malformed Unicode escape is encountered.

Processes C-style escape sequences including hex, octal, and Unicode.

str l0_string_escape::encode_c_string_bytes(bytes data)

Encode raw bytes into a C-safe string literal body.

Parameters
data The raw bytes to encode.
Returns A string containing the encoded C literal content (without quotes).

Uses standard escapes for common control characters and fixed-width octal escapes for other non-printable bytes to avoid ambiguity in C.

Variable documentation

str l0_string_escape::_HEX_CHARS protected

str l0_string_escape::_OCT_CHARS protected

dict l0_string_escape::_SIMPLE_ESCAPES protected