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 编辑过 |
关键字查询
相关文章
正在查询... |