[javascript]代码库
W.hasChinese = function(s) {
return /[\u4E00-\u9FA5]|[\uFE30-\uFFA0]/.test(s);
};
W.isChinese = function(s) {
return /^[\u4E00-\u9FA5]|^[\uFE30-\uFFA0]/.test(s);
};
W.hasJapanese = function(s) {
return /[\u0800-\u4e00]/.test(s);
};
W.isJapanese = function(s) {
return /^[\u0800-\u4e00]/.test(s);
};
W.hasKorean = function(s) {
return /[\u3130-\u318F]|[\uAC00-\uD7A3]/.test(s);
};
W.isKorean = function(s) {
return /^[\u3130-\u318F]|^[\uAC00-\uD7A3]/.test(s);
};
W.isDoubleByte = function(letter) {
return letter && letter.charCodeAt(0) > 255;
};
W.cn2Unicode = function(str) {
var i,
length,
chr,
unicode = '';
if (W.isStr(str)) {
for (i = 0, length = str.length; i < length; i++) {
chr = str[i];
unicode = W.hasChinese(chr) ? unicode + '\\u' + chr.charCodeAt(0).toString(16) : unicode + chr;
}
}
return unicode;
};