MCPcopy Create free account
hub / github.com/PageLeay/celestial-runtime / codePointToSymbol

Function codePointToSymbol

misc/test-browser/mocha.js:10580–10608  ·  view source on GitHub ↗
(codePoint, strict)

Source from the content-addressed store, hash-verified

10578
10579 // Modified version of `ucs2encode`; see https://mths.be/punycode.
10580 var codePointToSymbol = function(codePoint, strict) {
10581 var output = '';
10582 if ((codePoint >= 0xD800 && codePoint <= 0xDFFF) || codePoint > 0x10FFFF) {
10583 // See issue #4:
10584 // “Otherwise, if the number is in the range 0xD800 to 0xDFFF or is
10585 // greater than 0x10FFFF, then this is a parse error. Return a U+FFFD
10586 // REPLACEMENT CHARACTER.”
10587 if (strict) {
10588 parseError('character reference outside the permissible Unicode range');
10589 }
10590 return '\uFFFD';
10591 }
10592 if (has(decodeMapNumeric, codePoint)) {
10593 if (strict) {
10594 parseError('disallowed character reference');
10595 }
10596 return decodeMapNumeric[codePoint];
10597 }
10598 if (strict && contains(invalidReferenceCodePoints, codePoint)) {
10599 parseError('disallowed character reference');
10600 }
10601 if (codePoint > 0xFFFF) {
10602 codePoint -= 0x10000;
10603 output += stringFromCharCode(codePoint >>> 10 & 0x3FF | 0xD800);
10604 codePoint = 0xDC00 | codePoint & 0x3FF;
10605 }
10606 output += stringFromCharCode(codePoint);
10607 return output;
10608 };
10609
10610 var hexEscape = function(codePoint) {
10611 return '&#x' + codePoint.toString(16).toUpperCase() + ';';

Callers 1

decodeFunction · 0.85

Calls 3

parseErrorFunction · 0.85
hasFunction · 0.85
containsFunction · 0.85

Tested by

no test coverage detected