欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  web前端

lib.utf.js_lib_js

程序员文章站 2022-06-01 18:28:40
...
/* UTF-8  UTF-16 convertion library.
*
/* Copyright (C) 1999 Masanao Izumo iz@onicos.co.jp>
* 2007 Ma Bingyao andot@ujn.edu.cn>
* Version: 2.1
* LastModified: Feb 25, 2007
* This library is free. You can redistribute it and/or modify it.
*/


/*
* Interfaces:
* utf8 = utf16to8(utf16);
* utf16 = utf16to8(utf8);
*/


function utf16to8(str) {
if (str.match(/^[\x00-\x7f]*$/) != null) {
return str;
}
var out, i, j, len, c, c2;
out = [];
len = str.length;
for (i = 0, j = 0; i c = str.charCodeAt(i);
if (c out[j] = str.charAt(i);
}
else if (c out[j] = String.fromCharCode(0xc0 | (c >>> 6),
0x80 | (c & 0x3f));
}
else if (c ||
相关标签: lib.utf.js

推荐阅读