网络编程
位置:首页>> 网络编程>> Asp编程>> ASP中转换unicode编码为gb2312函数

ASP中转换unicode编码为gb2312函数

  发布时间:2007-10-22 17:46:00 

标签:unicode,gb,编码

ASP中转换unicode编码为GB编码方法:


<%
function urldecode(encodestr) 
newstr="" 
havechar=false 
lastchar="" 
for i=1 to len(encodestr) 
char_c=mid(encodestr,i,1) 
if char_c="+" then 
newstr=newstr & " " 
elseif char_c="%" then 
next_1_c=mid(encodestr,i+1,2) 
next_1_num=cint("&H" & next_1_c) 
if havechar then 
havechar=false 
newstr=newstr & chr(cint("&H" & lastchar & next_1_c)) 
else 
if abs(next_1_num)<=127 then 
newstr=newstr & chr(next_1_num) 
else 
havechar=true 
lastchar=next_1_c 
end if 
end if 
i=i+2 
else 
newstr=newstr & char_c 
end if 
next 
urldecode=newstr 
end function 
response.write urldecode("%B0%B5%B0%B5")
response.write Server.URLEncode("暗暗")
%>


0
投稿

猜你喜欢

手机版 网络编程 asp之家 www.aspxhome.com