Skip to content

Commit

Permalink
Add \xHH Unicode escape code to basic strings (#796)
Browse files Browse the repository at this point in the history
  • Loading branch information
eksortso authored Jul 30, 2022
1 parent 18348af commit 61ad52a
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 7 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
* Allow trailing comma in inline tables.
* Clarify where and how dotted keys define tables.
* Add new `\e` shorthand for the escape character.
* Add \x00 notation to basic strings.

## 1.0.0 / 2021-01-11

Expand Down
5 changes: 3 additions & 2 deletions toml.abnf
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,9 @@ escape-seq-char =/ %x66 ; f form feed U+000C
escape-seq-char =/ %x6E ; n line feed U+000A
escape-seq-char =/ %x72 ; r carriage return U+000D
escape-seq-char =/ %x74 ; t tab U+0009
escape-seq-char =/ %x75 4HEXDIG ; uXXXX U+XXXX
escape-seq-char =/ %x55 8HEXDIG ; UXXXXXXXX U+XXXXXXXX
escape-seq-char =/ %x78 2HEXDIG ; xHH U+00HH
escape-seq-char =/ %x75 4HEXDIG ; uHHHH U+HHHH
escape-seq-char =/ %x55 8HEXDIG ; UHHHHHHHH U+HHHHHHHH

;; Multiline Basic String

Expand Down
11 changes: 6 additions & 5 deletions toml.md
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ the control characters other than tab (U+0000 to U+0008, U+000A to U+001F,
U+007F).

```toml
str = "I'm a string. \"You can quote me\". Name\tJos\u00E9\nLocation\tSF."
str = "I'm a string. \"You can quote me\". Name\tJos\xE9\nLocation\tSF."
```

For convenience, some popular characters have a compact escape sequence.
Expand All @@ -281,12 +281,13 @@ For convenience, some popular characters have a compact escape sequence.
\e - escape (U+001B)
\" - quote (U+0022)
\\ - backslash (U+005C)
\uXXXX - unicode (U+XXXX)
\UXXXXXXXX - unicode (U+XXXXXXXX)
\xHH - unicode (U+00HH)
\uHHHH - unicode (U+HHHH)
\UHHHHHHHH - unicode (U+HHHHHHHH)
```

Any Unicode character may be escaped with the `\uXXXX` or `\UXXXXXXXX` forms.
The escape codes must be valid Unicode [scalar
Any Unicode character may be escaped with the `\xHH`, `\uHHHH`, or `\UHHHHHHHH`
forms. The escape codes must be valid Unicode [scalar
values](https://unicode.org/glossary/#unicode_scalar_value).

All other escape sequences not listed above are reserved; if they are used, TOML
Expand Down

0 comments on commit 61ad52a

Please sign in to comment.