内容显示页
 
类别:ASP+VBS | 浏览(493) | 2007-6-17 0:18:06 | 关闭广告
Function URLEncode(strURL)
    Dim I
    Dim tempStr
    For I = 1 ToLen(strURL)
        IfAsc(Mid(strURL, I, 1)) < 0 Then
            tempStr ="%"&Right(CStr(Hex(Asc(Mid(strURL, I, 1)))), 2)
            tempStr ="%"&Left(CStr(Hex(Asc(Mid(strURL, I, 1)))), Len(CStr(Hex(Asc(Mid(strURL, I, 1))))) - 2) & tempStr
            URLEncode = URLEncode & tempStr
        ElseIf (Asc(Mid(strURL, I, 1)) >= 65 AndAsc(Mid(strURL, I, 1)) <= 90) Or (Asc(Mid(strURL, I, 1)) >= 97 AndAsc(Mid(strURL, I, 1)) <= 122) Or (Asc(Mid(strURL, I, 1)) >= 48 AndAsc(Mid(strURL, I, 1)) <= 57) Then
            URLEncode = URLEncode &Mid(strURL, I, 1)
        Else
            URLEncode = URLEncode &"%"&Hex(Asc(Mid(strURL, I, 1)))
        EndIfNextEndFunctionFunction URLDecode(strURL)
    Dim I

    IfInStr(strURL, "%") = 0 Then
        URLDecode = strURL
        ExitFunctionEndIfFor I = 1 ToLen(strURL)
        IfMid(strURL, I, 1) ="%"ThenIfEval("&H"&Mid(strURL, I + 1, 2)) > 127 Then
                URLDecode = URLDecode &Chr(Eval("&H"&Mid(strURL, I + 1, 2) &Mid(strURL, I + 4, 2)))
                I = I + 5
            Else
                URLDecode = URLDecode &Chr(Eval("&H"&Mid(strURL, I + 1, 2)))
                I = I + 2
            EndIfElse
            URLDecode = URLDecode &Mid(strURL, I, 1)
        EndIfNextEndFunction



可修改代码后再运行


引用本页地址:http://www.yongfa365.com/item/vb-vbs-URLEncode-URLDecode.html
 
 
相关链接
 
网友评论:
姓名: 记住我
网址:
邮箱:
内容:
验证码:  验证码图片看不清? 换张图试试
 
   
 
 
文章分类
 
   

power by :柳永法(yongfa365)'Blog | model by :hibaidu | css by:众网友 | 京ICP备07011491号   我要统计  

本空间赞助商:北京中科兴联信息技术有限公司

QQ:64049027    E-mail:64049027<at>qq.com