ITADN

SPEC: Unicode character literals should use `\u{...}` syntax

#1805Opentothambrus11 创建于 2025-12-02
T
tothambrus11commented
The current syntax for custom unicode code points is the following: ```ebnf unicode-escape ::= (token) '\u' hexadecimal-digit+ ``` This makes it ambiguous if we want to write a unicode code point, followed by a character that's between A-F or a-f, as we cannot decide whether they are part of the hexadecimal digit sequence or the start of the rest of the string. While the JSON format explicitly requires exactly 4 hex digits (which doesn't cover all code points), Swift uses `\u{...}` syntax to disambiguate. Alternatively, we could use `\u(...)` and possibly even allow runtime values like `\(...)` does (this is probably not needed, but if the syntax is similar to the string interpolation, it would suggest that it should work like that).
3 条评论