MCPcopy Create free account
hub / github.com/RT-Thread/env-windows / parse_hex_char

Function parse_hex_char

tools/python-3.11.9-amd64/Lib/tomllib/_parser.py:501–509  ·  view source on GitHub ↗
(src: str, pos: Pos, hex_len: int)

Source from the content-addressed store, hash-verified

499
500
501def parse_hex_char(src: str, pos: Pos, hex_len: int) -> tuple[Pos, str]:
502 hex_str = src[pos : pos + hex_len]
503 if len(hex_str) != hex_len or not HEXDIGIT_CHARS.issuperset(hex_str):
504 raise suffixed_err(src, pos, "Invalid hex value")
505 pos += hex_len
506 hex_int = int(hex_str, 16)
507 if not is_unicode_scalar_value(hex_int):
508 raise suffixed_err(src, pos, "Escaped character is not a Unicode scalar value")
509 return pos, chr(hex_int)
510
511
512def parse_literal_str(src: str, pos: Pos) -> tuple[Pos, str]:

Callers 1

parse_basic_str_escapeFunction · 0.70

Calls 3

suffixed_errFunction · 0.70
is_unicode_scalar_valueFunction · 0.70
issupersetMethod · 0.45

Tested by

no test coverage detected