js字符编码
function toHex(val){
var str = new Array();
for(var i=0;i<val.length;i++){
var c = val.charCodeAt(i);
if(c>=0&&c<256){
str[str.length] = "//x" + val.charCodeAt(i).toString(16);
}else{
str[str.length] = "//u" + val.charCodeAt(i).toString(16);
}
}
return str.join("");
}
alert(toHex("中国abc"))