1// from: https://qiita.com/ka215/items/ace36f55c3ad1297de81 2 3export const encode = function (str) { 4 // eslint-disable-next-line no-control-regex 5 const reg = /[\u0000-\uFFFF<>&]/g; 6 return str.replace(reg, function (c) { 7 return typeof entityTable[c.charCodeAt(0)] != "undefined" 8 ? "&" + entityTable[c.charCodeAt(0)] + ";" 9 : c; 10 }); 11} 12 13export const decode = function (str) { 14 var elm = document.createElement("div"); 15 str = encodeURIComponent(str).replace(/%26/g, "&").replace(/%23/g, "#").replace(/%3B/g, ";"); 16 elm.innerHTML = decodeURIComponent(str); 17 str = elm.textContent; 18 if (elm.innerText) { 19 str = elm.innerText; 20 elm.innerText = ""; 21 } else { 22 str = elm.textContent; 23 elm.textContent = ""; 24 } 25 return str; 26} 27 28const entityTable = { 29 34: "quot", 30 38: "amp", 31 39: "apos", 32 60: "lt", 33 62: "gt", 34 160: "nbsp", 35 161: "iexcl", 36 162: "cent", 37 163: "pound", 38 164: "curren", 39 165: "yen", 40 166: "brvbar", 41 167: "sect", 42 168: "uml", 43 169: "copy", 44 170: "ordf", 45 171: "laquo", 46 172: "not", 47 173: "shy", 48 174: "reg", 49 175: "macr", 50 176: "deg", 51 177: "plusmn", 52 178: "sup2", 53 179: "sup3", 54 180: "acute", 55 181: "micro", 56 182: "para", 57 183: "middot", 58 184: "cedil", 59 185: "sup1", 60 186: "ordm", 61 187: "raquo", 62 188: "frac14", 63 189: "frac12", 64 190: "frac34", 65 191: "iquest", 66 192: "Agrave", 67 193: "Aacute", 68 194: "Acirc", 69 195: "Atilde", 70 196: "Auml", 71 197: "Aring", 72 198: "AElig", 73 199: "Ccedil", 74 200: "Egrave", 75 201: "Eacute", 76 202: "Ecirc", 77 203: "Euml", 78 204: "Igrave", 79 205: "Iacute", 80 206: "Icirc", 81 207: "Iuml", 82 208: "ETH", 83 209: "Ntilde", 84 210: "Ograve", 85 211: "Oacute", 86 212: "Ocirc", 87 213: "Otilde", 88 214: "Ouml", 89 215: "times", 90 216: "Oslash", 91 217: "Ugrave", 92 218: "Uacute", 93 219: "Ucirc", 94 220: "Uuml", 95 221: "Yacute", 96 222: "THORN", 97 223: "szlig", 98 224: "agrave", 99 225: "aacute", 100 226: "acirc", 101 227: "atilde", 102 228: "auml", 103 229: "aring", 104 230: "aelig", 105 231: "ccedil", 106 232: "egrave", 107 233: "eacute", 108 234: "ecirc", 109 235: "euml", 110 236: "igrave", 111 237: "iacute", 112 238: "icirc", 113 239: "iuml", 114 240: "eth", 115 241: "ntilde", 116 242: "ograve", 117 243: "oacute", 118 244: "ocirc", 119 245: "otilde", 120 246: "ouml", 121 247: "divide", 122 248: "oslash", 123 249: "ugrave", 124 250: "uacute", 125 251: "ucirc", 126 252: "uuml", 127 253: "yacute", 128 254: "thorn", 129 255: "yuml", 130 338: "OElig", 131 339: "oelig", 132 352: "Scaron", 133 353: "scaron", 134 376: "Yuml", 135 402: "fnof", 136 710: "circ", 137 732: "tilde", 138 913: "Alpha", 139 914: "Beta", 140 915: "Gamma", 141 916: "Delta", 142 917: "Epsilon", 143 918: "Zeta", 144 919: "Eta", 145 920: "Theta", 146 921: "Iota", 147 922: "Kappa", 148 923: "Lambda", 149 924: "Mu", 150 925: "Nu", 151 926: "Xi", 152 927: "Omicron", 153 928: "Pi", 154 929: "Rho", 155 931: "Sigma", 156 932: "Tau", 157 933: "Upsilon", 158 934: "Phi", 159 935: "Chi", 160 936: "Psi", 161 937: "Omega", 162 945: "alpha", 163 946: "beta", 164 947: "gamma", 165 948: "delta", 166 949: "epsilon", 167 950: "zeta", 168 951: "eta", 169 952: "theta", 170 953: "iota", 171 954: "kappa", 172 955: "lambda", 173 956: "mu", 174 957: "nu", 175 958: "xi", 176 959: "omicron", 177 960: "pi", 178 961: "rho", 179 962: "sigmaf", 180 963: "sigma", 181 964: "tau", 182 965: "upsilon", 183 966: "phi", 184 967: "chi", 185 968: "psi", 186 969: "omega", 187 977: "thetasym", 188 978: "upsih", 189 982: "piv", 190 8194: "ensp", 191 8195: "emsp", 192 8201: "thinsp", 193 8204: "zwnj", 194 8205: "zwj", 195 8206: "lrm", 196 8207: "rlm", 197 8211: "ndash", 198 8212: "mdash", 199 8216: "lsquo", 200 8217: "rsquo", 201 8218: "sbquo", 202 8220: "ldquo", 203 8221: "rdquo", 204 8222: "bdquo", 205 8224: "dagger", 206 8225: "Dagger", 207 8226: "bull", 208 8230: "hellip", 209 8240: "permil", 210 8242: "prime", 211 8243: "Prime", 212 8249: "lsaquo", 213 8250: "rsaquo", 214 8254: "oline", 215 8260: "frasl", 216 8364: "euro", 217 8465: "image", 218 8472: "weierp", 219 8476: "real", 220 8482: "trade", 221 8501: "alefsym",
222 8592: "larr", 223 8593: "uarr", 224 8594: "rarr", 225 8595: "darr", 226 8596: "harr", 227 8629: "crarr", 228 8656: "lArr", 229 8657: "uArr", 230 8658: "rArr", 231 8659: "dArr", 232 8660: "hArr", 233 8704: "forall", 234 8706: "part", 235 8707: "exist", 236 8709: "empty", 237 8711: "nabla", 238 8712: "isin", 239 8713: "notin", 240 8715: "ni", 241 8719: "prod", 242 8721: "sum", 243 8722: "minus", 244 8727: "lowast", 245 8730: "radic", 246 8733: "prop", 247 8734: "infin", 248 8736: "ang", 249 8743: "and", 250 8744: "or", 251 8745: "cap", 252 8746: "cup", 253 8747: "int", 254 8756: "there4", 255 8764: "sim", 256 8773: "cong", 257 8776: "asymp", 258 8800: "ne", 259 8801: "equiv", 260 8804: "le", 261 8805: "ge", 262 8834: "sub", 263 8835: "sup", 264 8836: "nsub", 265 8838: "sube", 266 8839: "supe", 267 8853: "oplus", 268 8855: "otimes", 269 8869: "perp", 270 8901: "sdot", 271 8968: "lceil", 272 8969: "rceil", 273 8970: "lfloor", 274 8971: "rfloor", 275 9001: "lang", 276 9002: "rang", 277 9674: "loz", 278 9824: "spades", 279 9827: "clubs", 280 9829: "hearts", 281 9830: "diams", 282};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.