百度空间 | 百度首页 
 
查看文章
 
ASP中文编码解码
2009-11-02 10:12

Server.URLEncode(“飞的更高”) 中文编码

解码函数:

function urldecode(encodestr)
Dim newstr,havechar,lastchar,i,char_c,next_1_c,next_1_Num
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


类别:asp,asp.net | 添加到搜藏 | 浏览() | 评论 (0)
 
最近读者:
 
网友评论:
发表评论:
姓 名:
网址或邮箱: (选填)
内 容:
验证码: 请点击后输入四位验证码,字母不区分大小写
      

     

©2009 Baidu