Created
May 21, 2013 08:31
-
-
Save thefish/5618339 to your computer and use it in GitHub Desktop.
JS utf-8 to windows-1251 string converter
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//utf8 to 1251 converter (1 byte format, RU/EN support only + any other symbols) by drgluck | |
function utf8_decode (aa) { | |
var bb = '', c = 0; | |
for (var i = 0; i < aa.length; i++) { | |
c = aa.charCodeAt(i); | |
if (c > 127) { | |
if (c > 1024) { | |
if (c == 1025) { | |
c = 1016; | |
} else if (c == 1105) { | |
c = 1032; | |
} | |
bb += String.fromCharCode(c - 848); | |
} | |
} else { | |
bb += aa.charAt(i); | |
} | |
} | |
return bb; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment