Skip to content

Commit 880092f

Browse files
committed
tomllib: Add \xHH Unicode escape code to basic strings (TOML 1.1)
1 parent 2342380 commit 880092f

3 files changed

Lines changed: 10 additions & 2 deletions

File tree

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
11
{
2-
"escape": {"type":"string","value":"\u001B"}
2+
"escape": {"type":"string","value":"\u001B"},
3+
"tab": {"type":"string","value":"\t"},
4+
"upper-j": {"type":"string","value":"J"},
5+
"upper-j-2": {"type":"string","value":"J"}
36
}
Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,4 @@
1-
escape = "\e"
1+
escape = "\e"
2+
tab = "\x09"
3+
upper-j = "\x4a"
4+
upper-j-2 = "\x4A"

Lib/tomllib/_parser.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -564,6 +564,8 @@ def parse_basic_str_escape(
564564
pos += 1
565565
pos = skip_chars(src, pos, TOML_WS_AND_NEWLINE)
566566
return pos, ""
567+
if escape_id == "\\x":
568+
return parse_hex_char(src, pos, 2)
567569
if escape_id == "\\u":
568570
return parse_hex_char(src, pos, 4)
569571
if escape_id == "\\U":

0 commit comments

Comments
 (0)