feat(compiler): Support braced Unicode escapes in template string literals#67269
Open
kbrilla wants to merge 3 commits intoangular:mainfrom
Open
feat(compiler): Support braced Unicode escapes in template string literals#67269kbrilla wants to merge 3 commits intoangular:mainfrom
kbrilla wants to merge 3 commits intoangular:mainfrom
Conversation
f18c605 to
1b1fbee
Compare
1b1fbee to
5c4e599
Compare
5c4e599 to
07e183e
Compare
JeanMeche
reviewed
Feb 25, 2026
| const hexStart = this.index; | ||
| while ( | ||
| this.input.charCodeAt(this.index) !== chars.$RBRACE && | ||
| this.input.charCodeAt(this.index) !== chars.$EOF && |
Member
There was a problem hiding this comment.
I don't think this condition is helpful. this.input.charCodeAt(this.length) equals NaN
Member
There was a problem hiding this comment.
could probably be writen as
while (this.index < this.length) {
const ch = this.input.charCodeAt(this.index);
if (ch === chars.$RBRACE) break;
this.advance();
}
Contributor
Author
There was a problem hiding this comment.
Thx for the catch! Applied your version.
JeanMeche
reviewed
Feb 25, 2026
|
|
||
| const hasClosingBrace = this.input.charCodeAt(this.index) === chars.$RBRACE; | ||
| const hex = this.input.substring(hexStart, this.index); | ||
| unicodeEscapeForError = `\\u{${hex}}`; |
Member
There was a problem hiding this comment.
wdyt ?
unicodeEscapeForError = hasClosingBrace ? \u{${hex}}:\u{${hex};
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Braced Unicode escapes in Angular template string literals
Scope (feature-only)
This PR adds support for ES6 braced Unicode escapes in Angular template expression string literals:
{{ '\u{4f60}' }}->你(CJK character){{ '\u{1F600}' }}->😀(emoji, above U+FFFF){{ '\u4f60' }}-> still works (traditional 4-digit form)Additional validated sequence example:
\u{48}\u{65}\u{6C}\u{6C}\u{6F}->HelloWorking example:

What changed
\uXXXX\u{...}> 0xFFFF) viaString.fromCodePoint(...).你)😀)HelloCharacter mapping
\u{...})\u{48}\u0048\u{65}\u0065\u{6C}\u006C\u{6F}\u006F\u{1F680}\uD83D\uDE80(Pair)\u{1F48E}\uD83D\uDC8E(Pair)\u{1F9E9}\uD83E\uDDE9(Pair)\u{130F0}\uD80C\uDCF0(Pair)Key takeaways
\uXXXXis limited to 16 bits (65,536 combinations). Modern Unicode extends to 21-bit code points (astral planes) used by many emoji and historic scripts.\u{...}is the modern ES6 form. It directly expresses code points without manual surrogate math or zero-padding.Tests run
pnpm bazel test //packages/compiler/test:test --test_filter=".*unicode braced escapes.*" --test_output=errors(passed)pnpm bazel test //packages/compiler/test:test --test_output=errors(passed)Notes
\uXXXXbehavior is preserved.AI disclosure
AI assisted with implementation and drafting under user direction; all changes were reviewed and validated with local tests before opening this PR.