(codePoint, strict)
| 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() + ';'; |
no test coverage detected