【Asp】Asp Url编码和解码(16进制编/解码)

admin 2021年4月3日19:02:55评论32 views字数 1859阅读6分11秒阅读模式

Asp Url编码和解码(16进制编码和解码):

function urldecoding(vstrin) 'URl解码
'qiushuiwuhen(2002-6-19)
    dim i,strreturn,strSpecial
    strSpecial = "!""#$%&'()*+,/:;?@[]^`{|}~%"
    strreturn = ""
    for i = 1 to len(vstrin)    
        thischr = mid(vstrin,i,1)
        if thischr="%" then
            intasc=eval("&h"+mid(vstrin,i+1,2))
            if instr(strSpecial,chr(intasc))>0 then
                strreturn= strreturn & chr(intasc)
                i=i+2
            else
                intasc=eval("&h"+mid(vstrin,i+1,2)+mid(vstrin,i+4,2))
                strreturn= strreturn & chr(intasc)
                i=i+5
            end if
        else
            if thischr="+" then
                strreturn= strreturn & " "
            else
                strreturn= strreturn & thischr
            end if
        end if
    next
    urldecoding = strreturn
end function

function urlencoding(vstrin) 'URl编码
    dim i,strreturn,strSpecial
    strSpecial = "!""#$%&'()*+,/:;?@[]^`{|}~%"
    strreturn = ""
    for i = 1 to len(vstrin)
        thischr = mid(vstrin,i,1)
        if abs(asc(thischr)) 
            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 
                innercode = innercode + &h10000
            end if
            hight8 = (innercode  and &hff00) &hff
            low8 = innercode and &hff
            strreturn = strreturn & "%" & hex(hight8) &  "%" & hex(low8)
        end if
    next
    urlencoding = strreturn
end function
%>

文章来源于lcx.cc:【Asp】Asp Url编码和解码(16进制编/解码)

相关推荐: 【VB】VB Sqr 求算术平方根 计算算术平方根

    VB Sqr 求算术平方根,VB Sqr 计算算术平方根,VB Sqr 算术平方根,VB Sqr 计算平方根,VB Sqr 求平方根,VB Sqr 算平方根,VB Sqr 算平方根,VB Sqr 平方根,VB Sqr 平方根,VB 平方根,VB Sqr…

  • 左青龙
  • 微信扫一扫
  • weinxin
  • 右白虎
  • 微信扫一扫
  • weinxin
admin
  • 本文由 发表于 2021年4月3日19:02:55
  • 转载请保留本文链接(CN-SEC中文网:感谢原作者辛苦付出):
                   【Asp】Asp Url编码和解码(16进制编/解码)https://cn-sec.com/archives/319713.html

发表评论

匿名网友 填写信息