hex_digit_value
def hex_digit_value(c: UInt8) -> Int Convert a hex digit character to its value.
Returns -1 if not a valid hex digit.
json_mlake ยท API
json.unicodehex_digit_valuedef hex_digit_value(c: UInt8) -> Int Convert a hex digit character to its value.
Returns -1 if not a valid hex digit.
parse_unicode_escapedef parse_unicode_escape(data: List[UInt8], start: Int) -> Int Parse a 4-digit hex unicode escape sequence.
data: The byte span containing the escape.start: Index of first hex digit (after backslash-u).parse_unicode_escape_spandef parse_unicode_escape_span(data: Span[UInt8], start: Int) -> Int parse_unicode_escape overload that accepts a borrowed byte span.
Used by the tape stage 2 string emitter so it doesn't have to copy
the whole input into a List[UInt8] per string with escapes.
is_high_surrogatedef is_high_surrogate(code_point: Int) -> Bool Check if code point is a high surrogate (U+D800 - U+DBFF).
is_low_surrogatedef is_low_surrogate(code_point: Int) -> Bool Check if code point is a low surrogate (U+DC00 - U+DFFF).
decode_surrogate_pairdef decode_surrogate_pair(high: Int, low: Int) -> Int Decode a surrogate pair to a full code point.
high: High surrogate (U+D800 - U+DBFF).low: Low surrogate (U+DC00 - U+DFFF).encode_utf8def encode_utf8(code_point: Int, mut bytes: List[UInt8]) Encode a Unicode code point as UTF-8 bytes.
code_point: Unicode code point (0 - 0x10FFFF).bytes: List to append UTF-8 bytes to.unescape_json_string_spandef unescape_json_string_span(data: Span[UInt8], start: Int, end: Int) -> List[UInt8] unescape_json_string overload that accepts a borrowed byte span.
Avoids the O(input_size) copy from List[UInt8] per string when
only a tiny slice between the quotes contains escapes. Same
behaviour as the List[UInt8] overload below; defined inline so
we don't need a generic dispatch helper.
unescape_json_stringdef unescape_json_string(data: List[UInt8], start: Int, end: Int) -> List[UInt8] Unescape a JSON string, handling all escape sequences including unicode.
data: The byte span containing the string content.start: Start index (after opening quote).end: End index (before closing quote).