- ·上一篇文章:asp session 使用数组
- ·下一篇文章:简单的asp操作access例子源码
全角与半角字符的相互转换的asp函数
为了防止客户在输入的时候,错误地输入了全角(半角)字符,我们要通过程序将它转换成正确的半角(全角)字符,这是给定的函数。
<
% 
&
#39
**************************** 
&
#39
*参数说明: 
&
#39
* 
str:要转换的字符串 
&
#39
* 
flag:标记,为0时半转全,为非0时全转半 
&
#39
* 
返回值类型:字符串 
&
#39
**************************** 
function 
DBC2SBC(str,flag) 
dim 
i 
if 
len(str)<
=0 
then 
REsponse.Write("
字符串参数为空"
) 
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&
#38
chr(asc(mid(str,i,1))-23680) 
else 
dbc2sbc=dbc2sbc&
#38
chr(asc(mid(str,i,1))+23680) 
end 
if 
next 
End 
function 
%>
<
% 
&
#39
**************************** 
&
#39
*参数说明: 
&
#39
* 
str:要转换的字符串 
&
#39
* 
flag:标记,为0时半转全,为非0时全转半 
&
#39
* 
返回值类型:字符串 
&
#39
**************************** 
function 
DBC2SBC(str,flag) 
dim 
i 
if 
len(str)<
=0 
then 
REsponse.Write("
字符串参数为空"
) 
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&
#38
chr(asc(mid(str,i,1))-23680) 
else 
dbc2sbc=dbc2sbc&
#38
chr(asc(mid(str,i,1))+23680) 
end 
if 
next 
End 
function 
%>
全角与半角字符的相互转换的asp函数