Skip to content

Commit b796c1d

Browse files
committed
Updated unicode escape documentation to match current implementation.
Unicode escapes were changed in [this RFC](https://github.com/rust-lang/rfcs/blob/28aeb3c391c9afd344f124d3a69bdc2a420638b2/text/0446-es6-unicode-escapes.md) to use the ES6 \u{00FFFF} syntax with a variable number of digits from 1-6, eliminating the need for two different syntaxes for unicode literals.
1 parent f1398d2 commit b796c1d

File tree

2 files changed

+7
-12
lines changed

2 files changed

+7
-12
lines changed

src/doc/grammar.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -196,8 +196,7 @@ raw_string : '"' raw_string_body '"' | '#' raw_string '#' ;
196196
common_escape : '\x5c'
197197
| 'n' | 'r' | 't' | '0'
198198
| 'x' hex_digit 2
199-
unicode_escape : 'u' hex_digit 4
200-
| 'U' hex_digit 8 ;
199+
unicode_escape : 'u' '{' hex_digit+ 6 '}';
201200
202201
hex_digit : 'a' | 'b' | 'c' | 'd' | 'e' | 'f'
203202
| 'A' | 'B' | 'C' | 'D' | 'E' | 'F'

src/doc/reference.md

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -250,8 +250,7 @@ cases mentioned in [Number literals](#number-literals) below.
250250
##### Unicode escapes
251251
| | Name |
252252
|---|------|
253-
| `\u7FFF` | 16-bit character code (exactly 4 digits) |
254-
| `\U7EEEFFFF` | 32-bit character code (exactly 8 digits) |
253+
| `\u{7FFF}` | 24-bit Unicode character code (up to 6 digits) |
255254

256255
##### Numbers
257256

@@ -286,8 +285,8 @@ raw_string : '"' raw_string_body '"' | '#' raw_string '#' ;
286285
common_escape : '\x5c'
287286
| 'n' | 'r' | 't' | '0'
288287
| 'x' hex_digit 2
289-
unicode_escape : 'u' hex_digit 4
290-
| 'U' hex_digit 8 ;
288+
289+
unicode_escape : 'u' '{' hex_digit+ 6 '}';
291290
292291
hex_digit : 'a' | 'b' | 'c' | 'd' | 'e' | 'f'
293292
| 'A' | 'B' | 'C' | 'D' | 'E' | 'F'
@@ -320,12 +319,9 @@ following forms:
320319
* An _8-bit codepoint escape_ escape starts with `U+0078` (`x`) and is
321320
followed by exactly two _hex digits_. It denotes the Unicode codepoint
322321
equal to the provided hex value.
323-
* A _16-bit codepoint escape_ starts with `U+0075` (`u`) and is followed
324-
by exactly four _hex digits_. It denotes the Unicode codepoint equal to
325-
the provided hex value.
326-
* A _32-bit codepoint escape_ starts with `U+0055` (`U`) and is followed
327-
by exactly eight _hex digits_. It denotes the Unicode codepoint equal to
328-
the provided hex value.
322+
* A _24-bit codepoint escape_ starts with `U+0075` (`u`) and is followed
323+
by up to six _hex digits_ surrounded by braces `U+007B` (`{`) and `U+007D`
324+
(`}`). It denotes the Unicode codepoint equal to the provided hex value.
329325
* A _whitespace escape_ is one of the characters `U+006E` (`n`), `U+0072`
330326
(`r`), or `U+0074` (`t`), denoting the unicode values `U+000A` (LF),
331327
`U+000D` (CR) or `U+0009` (HT) respectively.

0 commit comments

Comments
 (0)