当前位置:首页 > ASP教程 > 应用技巧

asp下实现UrlEncoding转换编码的代码

'==================================================
'函数名:urlencoding
'作  用:转换编码
'==================================================
function urlencoding(datastr)
    dim strreturn,si,thischr,innercode,hight8,low8
    strreturn = ""
    for si = 1 to len(datastr)
        thischr = mid(datastr,si,1)
        if abs(asc(thischr)) < &hff then
            strreturn = strreturn & thischr
        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
    urlencoding = strreturn
end function
【说明】本文章由站长整理发布,文章内容不代表本站观点,如文中有侵权行为,请与本站客服联系(QQ:)!