為了防止客戶在輸入的時候,錯誤地輸入了全角(半角)字符,我們要通過程序?qū)⑺D(zhuǎn)換成正確的半角(全角)字符,這是給定的函數(shù)。 <% '**************************** '*參數(shù)說明: '* str:要轉(zhuǎn)換的字符串 '* flag:標記,為0時半轉(zhuǎn)全,為非0時全轉(zhuǎn)半 '* 返回值類型:字符串 '**************************** function DBC2SBC(str,flag) dim i if len(str)<=0 then REsponse.Write("字符串參數(shù)為空") 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 %>