资讯淘帖 手机客户端
圈子家园文章新帖搜索公交查询店铺点评金山快盘实验室网盘教案管理2012上网客户端开启辅助访问

127社区-师生共同的网上家园

 找回密码
 立即注册

QQ登录

只需一步,快速开始

用新浪微博连接

一步搞定

关闭

站长推荐

亲,还没下载论坛手机客户端?跟上潮流做时尚达人。掌中乐趣无处不在,快点下载吧。

查看 »

ASP地址栏URL编码与解码函数

2010-7-12 00:48| 发布者: 小平| 查看: 335| 评论: 0

<%
'url编码函数
function urlencode(vstrin)
    dim i,strreturn,strSpecial
    strSpecial = "!""#$%&'()*+,/:;<=>?@[\]^`{|}~%"
    strreturn = ""
    for i = 1 to len(vstrin)
        thischr = mid(vstrin,i,1)
        if abs(asc(thischr)) < &hff then
         if thischr=" " then
          strreturn = strreturn & "+"
            elseif instr(strSpecial,thischr)>0 then
                strreturn = strreturn & "%" & hex(asc(thischr))
            else
                strreturn = strreturn & thischr
            end if
        else
            innercode = asc(thischr)
            if innercode < 0 then
                innercode = innercode + &h10000
            end if
            hight8 = (innercode  and &hff00)\ &hff
            low8 = innercode and &hff
            strreturn = strreturn & "%" & hex(hight8) &  "%" & hex(low8)
        end if
    next
    urlencode= strreturn
end function

'url解码函数
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
%>


鲜花

握手

雷人

路过

鸡蛋

最新评论

插件友情推广计划插件友情推广计划插件友情推广计划

手机客户端|Archiver|127社区-师生共同的网上家园 ( 渝ICP备10016736号 )  |  

GMT+8, 2013-3-25 18:59

Powered by Discuz! X2.5

© 2001-2012 Comsenz Inc.

回顶部