var koi2utf={ 163:1105, 179:1025, 192:1102, 193:1072, 194:1073, 195:1094, 196:1076, 197:1077, 198:1092, 199:1075, 200:1093, 201:1080, 202:1081, 203:1082, 204:1083, 205:1084, 206:1085, 207:1086, 208:1087, 209:1103, 210:1088, 211:1089, 212:1090, 213:1091, 214:1078, 215:1074, 216:1100, 217:1099, 218:1079, 219:1096, 220:1101, 221:1097, 222:1095, 223:1098 }; function koi2unicode (str){ if (str == null){ return null;} var result = ""; var o_code = ""; var i_code = ""; for (var I=0; I < str.length; I++){ i_code = str.charCodeAt(I); if (koi2utf[i_code] != null){ o_code = koi2utf[i_code]; } else if (i_code > 223 && koi2utf[i_code-32] != null){ o_code = koi2utf[i_code-32]-32; } else { o_code = i_code; } result = result + String.fromCharCode(o_code); } return result; } function win2unicode (str){ if (str == null){ return null;} var result = ""; var o_code = ""; var i_code = ""; for (var I=0; I < str.length; I++){ i_code = str.charCodeAt(I); if (i_code == 184){ o_code = 1105; } else if (i_code == 168){ o_code = 1025; } else if (i_code > 191 && i_code < 256){ o_code = i_code + 848; } else { o_code = i_code; } result = result + String.fromCharCode(o_code); } return result; } URL: Обсуждается: http://www.opennet.me/tips/info/915.shtml
|