(codePoint, strict)
| 94 | |
| 95 | // Modified version of `ucs2encode`; see https://mths.be/punycode. |
| 96 | var codePointToSymbol = function(codePoint, strict) { |
| 97 | var output = ''; |
| 98 | if ((codePoint >= 0xD800 && codePoint <= 0xDFFF) || codePoint > 0x10FFFF) { |
| 99 | // See issue #4: |
| 100 | // “Otherwise, if the number is in the range 0xD800 to 0xDFFF or is |
| 101 | // greater than 0x10FFFF, then this is a parse error. Return a U+FFFD |
| 102 | // REPLACEMENT CHARACTER.” |
| 103 | if (strict) { |
| 104 | parseError('character reference outside the permissible Unicode range'); |
| 105 | } |
| 106 | return '\uFFFD'; |
| 107 | } |
| 108 | if (has(decodeMapNumeric, codePoint)) { |
| 109 | if (strict) { |
| 110 | parseError('disallowed character reference'); |
| 111 | } |
| 112 | return decodeMapNumeric[codePoint]; |
| 113 | } |
| 114 | if (strict && contains(invalidReferenceCodePoints, codePoint)) { |
| 115 | parseError('disallowed character reference'); |
| 116 | } |
| 117 | if (codePoint > 0xFFFF) { |
| 118 | codePoint -= 0x10000; |
| 119 | output += stringFromCharCode(codePoint >>> 10 & 0x3FF | 0xD800); |
| 120 | codePoint = 0xDC00 | codePoint & 0x3FF; |
| 121 | } |
| 122 | output += stringFromCharCode(codePoint); |
| 123 | return output; |
| 124 | }; |
| 125 | |
| 126 | var hexEscape = function(codePoint) { |
| 127 | return '&#x' + codePoint.toString(16).toUpperCase() + ';'; |
no test coverage detected