/*
* Full-angle space is 12288, half a corner space is 32
* The corresponding relation of the other character half angle (33-126) and the whole angle (65281-65374) is: The difference is 65248
*/
function SBC (text) {
Return Text.replace (/[x20-x7e]/g, function ($) {
return $ = = ""? u3000 ": String.fromCharCode ($.charcodeat (0) + 0xfee0);
});
}
var todbc=function (input) {//to DBC case
var res= "", C;
for (var i=0;i< input.length;i++) {
C=input.charcodeat (i);
if (c >=0xff01 && C <=0xff5e)//65281 65374
Res+=string.fromcharcode (C-0XFEE0);//65248
else if (c==0x3000)//12288
Res+=string.fromcharcode (0x20);//32
Else
Res+=input.charat (i);
}
return res;
}
var tosbc=function (input) {//to SBC case
var res= "", C;
for (Var i=0 i < input.length;i++) {
C=input.charcodeat (i);
if (c>=0x21 && c<=0x7e)//33 126
Res+=string.fromcharcode (C+0XFEE0);
else if (c==0x20)
res = String.fromCharCode (0x3000);
Else
res = Input.charat (i);
}
return res;
}
var s= ", oh Oh, hello ssss! #~ ";
var s1=todbc (s);
var s2=tosbc (S1);
Alert ("Original character:" +s+ "NNTODBC:" +s1+ "NNTOSBC:" +S2);