ASP中的全角和半角之間的轉化
當前位置:點晴教程→知識管理交流
→『 技術文檔交流 』
[p]sp中的全角和半角之間的轉化[br][br]<% [br]function dbc2sbc(str, flag) [br]rem 全角半角轉換函數 [br]rem flag=-1時進行半角轉全角 [br]rem flag=0時進行半角全角互轉 [br]rem flag=1時進行全角轉半角 [br]dim i, sstr [br]if len(str)<= 0 then exit function [br]dbc2sbc = "" [br]for i = 1 to len(str) [br]sstr = asc(mid(str, i, 1)) [br]select case flag [br]case -1 [br]if sstr>0 and sstr<= 125 then [br]dbc2sbc = dbc2sbc & chr(asc(mid(str, i, 1)) -23680) [br]else [br]dbc2sbc = dbc2sbc & mid(str, i, 1) [br]end if [br]case 0 [br]if sstr>0 and sstr<= 125 then [br]dbc2sbc = dbc2sbc & chr(asc(mid(str, i, 1)) -23680) [br]else [br]dbc2sbc = dbc2sbc & chr(asc(mid(str, i, 1)) + 23680) [br]end if [br]case 1 [br]if sstr<0 or sstr>125 then [br]dbc2sbc = dbc2sbc & chr(asc(mid(str, i, 1)) + 23680) [br]else [br]dbc2sbc = dbc2sbc & mid(str, i, 1) [br]end if [br]end select [br]next [br]end function [br]%>[br]測試代碼:[br][br]key="關鍵詞:點晴mis管理信息系統 [url=http://clicksun.com][color=#000000]clicksun[/color].com[/url].cn"[br]response.write ""&key&""[br]response.write "
半角轉全角: "&dbc2sbc(key,-1)[br]response.write " 半角全角互轉: "&dbc2sbc(key,0)[br]response.write " 全角轉半角: "&dbc2sbc(key,1)[/p] 該文章在 2010/7/23 0:14:33 編輯過 |
關鍵字查詢
相關文章
正在查詢... |