.gitignore added
[dotfiles/.git] / .config / coc / extensions / node_modules / coc-prettier / node_modules / entities / lib / decode_codepoint.js
1 var decodeMap = require("../maps/decode.json");
2
3 module.exports = decodeCodePoint;
4
5 // modified version of https://github.com/mathiasbynens/he/blob/master/src/he.js#L94-L119
6 function decodeCodePoint(codePoint) {
7     if ((codePoint >= 0xd800 && codePoint <= 0xdfff) || codePoint > 0x10ffff) {
8         return "\uFFFD";
9     }
10
11     if (codePoint in decodeMap) {
12         codePoint = decodeMap[codePoint];
13     }
14
15     var output = "";
16
17     if (codePoint > 0xffff) {
18         codePoint -= 0x10000;
19         output += String.fromCharCode(((codePoint >>> 10) & 0x3ff) | 0xd800);
20         codePoint = 0xdc00 | (codePoint & 0x3ff);
21     }
22
23     output += String.fromCharCode(codePoint);
24     return output;
25 }