function tobanjiao(str) {
var result="";
for (var i = 0; i < str.length; i++)
{
if (str.charCodeAt(i)==12288)
{
result+= String.fromCharCode(str.charCodeAt(i)-12256);
continue;
}
if (str.charCodeAt(i)>65280 && str.charCodeAt(i)<65375)
result+= String.fromCharCode(str.charCodeAt(i)-65248);
else result+= String.fromCharCode(str.charCodeAt(i));
}
return result;
}
function toquanjiao(mystr) {
var result="";
for (var i=0; i < mystr.length ;i++)
{
if(mystr.charCodeAt(i)==32)
{
result+= String.fromCharCode(str.charCodeAt(i)+12256);
continue;
}
if ( mystr.charCodeAt(i)<127 )
result+= String.fromCharCode(mystr.charCodeAt(i)+65248);
}
return result;
}
我自己写的js 全角半角互相转化函数
最新推荐文章于 2024-01-08 16:42:55 发布