1.9 KiB
1.9 KiB
Bare Key Characters in TOML v1.1
In TOML v1.1, the definition of a bare key (unquoted key) has been significantly expanded from the strict ASCII-only restriction of TOML v1.0 to support internationalization.
1. The TOML v1.0 Definition (Legacy)
In TOML v1.0, a bare key could only contain:
- ASCII letters (
A-Z,a-z) - ASCII digits (
0-9) - Underscores (
_) - Dashes (
-)
2. The TOML v1.1 Expansion
TOML v1.1 allows non-ASCII Unicode characters in bare keys. The character ranges are largely aligned with the XML 1.1 NameChar specification, which covers most letters, digits, and combining marks from scripts worldwide.
A bare-key-char in TOML v1.1 is defined as:
- Any character allowed in v1.0 (
[A-Za-z0-9_-]). - Any non-ASCII Unicode codepoint from the following specific ranges:
U+00B2,U+00B3,U+00B9(Superscripts)U+00BCtoU+00BE(Fractions)U+00C0toU+00D6U+00D8toU+00F6U+00F8toU+037DU+037FtoU+1FFFU+200CtoU+200D(Zero-width joiners)U+203FtoU+2040U+2070toU+218FU+2460toU+24FFU+2C00toU+2FEFU+3001toU+D7FFU+F900toU+FDCFU+FDF0toU+FFFDU+10000toU+EFFFF(Supplementary Planes)
Summary Table
| Feature | TOML v1.0 | TOML v1.1 |
|---|---|---|
| Allowed Characters | [A-Za-z0-9_-] |
[A-Za-z0-9_-] + Wide Unicode ranges |
| Examples | key = "val" |
café = "coffee", ñoño = "val", 日本語 = "val" |
| Prohibited | café = "val" (must use "café") |
Whitespace, ., [, ], #, =, etc. |
Implementation Status in tomlc17
The tomlc17 project recently updated its scanner in commit df7ecd4 to support these TOML v1.1 ranges using a new helper function is_unicode_bare_key_char(). This allows the parser to correctly handle unquoted internationalized keys.