/*
****************************
* 半角<=>全角 *
* [NB联盟] *
* Writer YuPing *
****************************
* 参数说明:
* str:要转换的字符串
* flag:标记,为0时半转全,为非0时全转半
* 返回值类型:字符串
****************************
*/
function DBC2SBC(str,flag) {
var i;
var result='';
if (str.length<=0) {alert('字符串参数出错');return false;}
for(i=0;i { str1=str.charCodeAt(i); if(str1<125&&!flag) result+=String.fromCharCode(str.charCodeAt(i)+65248); else result+=String.fromCharCode(str.charCodeAt(i)-65248); } return result; } //示例: alert(DBC2SBC("AAabc",0)); document.write(DBC2SBC("abcdefg",0)) '**************************** '* 半角<=>全角 * '* [NB联盟] * '* Writer YuPing * '**************************** '* 参数说明: '* str:要转换的字符串 '* flag:标记,为0时半转全,为非0时全转半 '* 返回值类型:字符串 '**************************** function DBC2SBC(str,flag) dim i if len(str)<=0 then msgbox '字符串参数出错' exit function end if for i=1 to len(str) str1=asc(mid(str,i,1)) if str1>0 and str1<=125 and not flag then dbc2sbc=dbc2sbc&chr(asc(mid(str,i,1))-23680) else dbc2sbc=dbc2sbc&chr(asc(mid(str,i,1))+23680) end if next end function '示例: alert(dbc2sbc("AB",1))

