fix: \char support for >16-bit Unicode characters (#3006)

* fix: \char support for >16-bit Unicode characters

`String.fromCharCode` only supports Unicode characters up to 16-bit.
`String.fromCodePoint` from ECMAScript 2015 supports all Unicode code points.
Unfortunately, IE doesn't support the latter, so use former as fallback.

Fixes #3004

Co-authored-by: ylemkimon <y@ylem.kim>
This commit is contained in:
Erik Demaine
2021-08-28 18:55:05 -04:00
committed by GitHub
parent 90dcaef2bd
commit ff1734f7c4
2 changed files with 19 additions and 2 deletions

View File

@@ -3313,6 +3313,12 @@ describe("A macro expander", function() {
expect(parsedChar[0].type).toEqual("textord");
});
it("\\char handles >16-bit characters", () => {
const parsed = getParsed('\\char"1d7d9');
expect(parsed[0].type).toEqual("textord");
expect(parsed[0].text).toEqual("𝟙");
});
it("should build Unicode private area characters", function() {
expect`\gvertneqq\lvertneqq\ngeqq\ngeqslant\nleqq`.toBuild();
expect`\nleqslant\nshortmid\nshortparallel\varsubsetneq`.toBuild();