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
l0_ string_ escape:: _TRIGRAPH_THIRD_BYTES protected
dict l0_ string_ escape:: _SIMPLE_ESCAPES protected