MCPcopy Create free account
hub / github.com/microsoft/SandDance / scanUnicodeCodePointEscape

Function scanUnicodeCodePointEscape

docs/tests/v2/es6/js/sanddance.js:128053–128084  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

128051}
128052
128053function scanUnicodeCodePointEscape() {
128054 var ch, code, cu1, cu2;
128055 ch = source[index];
128056 code = 0; // At least, one hex digit is required.
128057
128058 if (ch === '}') {
128059 throwError({}, MessageUnexpectedToken, ILLEGAL);
128060 }
128061
128062 while (index < length) {
128063 ch = source[index++];
128064
128065 if (!isHexDigit(ch)) {
128066 break;
128067 }
128068
128069 code = code * 16 + '0123456789abcdef'.indexOf(ch.toLowerCase());
128070 }
128071
128072 if (code > 0x10FFFF || ch !== '}') {
128073 throwError({}, MessageUnexpectedToken, ILLEGAL);
128074 } // UTF-16 Encoding
128075
128076
128077 if (code <= 0xFFFF) {
128078 return String.fromCharCode(code);
128079 }
128080
128081 cu1 = (code - 0x10000 >> 10) + 0xD800;
128082 cu2 = (code - 0x10000 & 1023) + 0xDC00;
128083 return String.fromCharCode(cu1, cu2);
128084}
128085
128086function getEscapedIdentifier() {
128087 var ch, id;

Callers 1

scanStringLiteralFunction · 0.70

Calls 2

throwErrorFunction · 0.70
isHexDigitFunction · 0.70

Tested by

no test coverage detected