nakarte

Source code of https://map.sikmir.ru (fork)
git clone git://git.sikmir.ru/nakarte
Log | Files | Refs | LICENSE

codePages.js (883B)


      1 function decode866(s) {
      2     var c, i,
      3         s2 = [];
      4     for (i = 0; i < s.length; i++) {
      5         c = s.charCodeAt(i);
      6         if (c >= 128 && c <= 175) {
      7             c += (0x410 - 128);
      8         } else if (c >= 224 && c <= 239) {
      9             c += (0x440 - 224);
     10         } else if (c === 240) {
     11             c = 0x0401;
     12         } else if (c === 241) {
     13             c = 0x0451;
     14         }
     15         s2.push(String.fromCharCode(c));
     16     }
     17     return s2.join('');
     18 }
     19 
     20 function decodeCP1251(s) {
     21     var c, i,
     22         s2 = [];
     23     for (i = 0; i < s.length; i++) {
     24         c = s.charCodeAt(i);
     25         if (c >= 192 && c <= 255) {
     26             c += (0x410 - 192);
     27         } else if (c === 168) {
     28             c = 0x0401;
     29         } else if (c === 184) {
     30             c = 0x0451;
     31         }
     32         s2.push(String.fromCharCode(c));
     33     }
     34     return s2.join('');
     35 }
     36 
     37 export {decode866, decodeCP1251};
     38