Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for extended Unicode escape sequences in strings and templates #2169

Conversation

DanielRosenwasser
Copy link
Member

Fixes #2047.

ES6 extended escapes take the form of \u{XXXXX...} where XXXXX... is any number of hex digits. It is a syntax error if the value of these digits is greater than 0x10FFFF. When interpreting the value of such a code point, it must be interpreted as two individual UTF16 codepoints through a well-defined encoding scheme.

Notable changes are:

  • We support extended ES6 escape sequences as is.
  • We support downlevel emit for ES6 escape sequences, using \uXXXX escapes for any non-ASCII characters in the original string.
  • Template strings always use \uXXXX escapes for any non-ASCII characters.

Things we still don't support:

  • Escapes in regular expressions.

@@ -155,6 +155,8 @@ module ts {
Catch_clause_variable_name_must_be_an_identifier: { code: 1195, category: DiagnosticCategory.Error, key: "Catch clause variable name must be an identifier." },
Catch_clause_variable_cannot_have_a_type_annotation: { code: 1196, category: DiagnosticCategory.Error, key: "Catch clause variable cannot have a type annotation." },
Catch_clause_variable_cannot_have_an_initializer: { code: 1197, category: DiagnosticCategory.Error, key: "Catch clause variable cannot have an initializer." },
An_extended_Unicode_escape_value_must_be_between_0x0_and_0x10FFFF_inclusive: { code: 1198, category: DiagnosticCategory.Error, key: "An extended Unicode escape value must be between 0x0 and 0x10FFFF inclusive." },
expected: { code: 1199, category: DiagnosticCategory.Error, key: "'}' expected." },
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

'Unterminated unicode escape'

DanielRosenwasser added a commit that referenced this pull request Mar 3, 2015
…ThereWouldntBeSoManyWaysToDoIt

Add support for extended Unicode escape sequences in strings and templates
@DanielRosenwasser DanielRosenwasser merged commit 7212912 into master Mar 3, 2015
@DanielRosenwasser DanielRosenwasser deleted the withANameLikeUnicodeYoudThinkThereWouldntBeSoManyWaysToDoIt branch March 3, 2015 20:16
@microsoft microsoft locked and limited conversation to collaborators Jun 18, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ES6 extended Unicode syntax for strings and template strings
4 participants