</pre><pre name= "Code" class= "JavaScript" >///full-width space is 12288, half-width space is 32///other character half-width (33-126) and full-width (65281-65374) The corresponding relationship is: all difference 65248//half-width conversion to full-width function todbc (txtstring) {var tmp = ""; for (Var i=0;i<txtstring.length;i++) {if (Txtstring.charcodeat (i) ==32) {tmp= tmp+ string.fromcharcode (12288);} if ( Txtstring.charcodeat (i) <127) {Tmp=tmp+string.fromcharcode (Txtstring.charcodeat (i) +65248);}} return TMP; }//full-width conversion to half-width function tocdb (str) {var tmp = ""; for (Var i=0;i<str.length;i++) {if (Str.charcodeat (i) >65248&&str.charcodeat (i) <65375) {tmp + = String.fromCharCode (Str.charcodeat (i)-65248); }else {tmp + = String.fromCharCode (Str.charcodeat (i));}} return TMP}
JavaScript Digital Full-width half-width conversion