|
|
URLDecode—ASP中与server.URLEncode相对应的解码函数 |
作者:admin 发表时间:2015/6/12 人气: |
|
|
ASP中server.URLEncode是用来对URL进行编码的,而编码后依然可以被浏览器所识别,所以一般情况下不需要用到解码函数,但并不是说其它地方用不到这个函数的,如最经常用的COOKIE,如果要保存的COOKIE为汉字的话,在读取的时候经常会出现乱码,所以最方便的方法就是用server.URLEncode对要保存的COOKIE值进行编码,然后再保存到COOKIE里,读取的时候再用下面的函数进行解码! 具体函数如下: '---------------------------------------------------------------- 'URLDecode 'ASP中与server.urlencode相对的解码函数 '参数:编码的字符串 '返回值:解码后的字符串 '---------------------------------------------------------------- Function URLDecode(enStr) dim deStr,strSpecial dim c,i,v deStr="" strSpecial="!""#$%&'()*+,.-_/:;<=>?@[\]^`{|}~%" for i=1 to len(enStr) c=Mid(enStr,i,1) if c="%" then v=eval("&h"+Mid(enStr,i+1,2)) if inStr(strSpecial,chr(v))>0 then deStr=deStr&chr(v) i=i+2 else v=eval("&h"+ Mid(enStr,i+1,2) + Mid(enStr,i+4,2)) deStr=deStr & chr(v) i=i+5 end if else if c="+" then deStr=deStr&" " else deStr=deStr&c end if end if next URLDecode=deStr End Function URLDecode—ASP中与server.URLEncode相对应的解码函数
文章来源:www.sensheng.net.cn |
文章点评 |
|
|
|
|
|