URL编码(转载)

默认分类 | 2021-04-20 20:00:37 | 阅读 93 次 | 评论(0)

来源:https://bbs.csdn.net/topics/390991766

作者:回马枪

Clear
? UrlEncode(' test,这是一个测试', .F.)  && .F. --> "+", .F. --> "%20"
Function UrlEncode(tcString, tlNoPlus)
    Local lcReturn, lcChar, lnCounter
    m.lcReturn=""
    For m.lnCounter = 1 To Len(m.tcString)
        m.lcChar = Substr(m.tcString, m.lnCounter, 1)
        If Atc(m.lcChar,"ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789") > 0
            m.lcReturn = m.lcReturn + m.lcChar
            Loop
        Endif
        If Asc(m.lcChar) = 32 And !m.tlNoPlus
            m.lcReturn = m.lcReturn + "+"
            Loop
        Endif
        m.lcReturn = m.lcReturn + "%" + Right(Transform(Asc(m.lcChar),"@0"),2)
    Endfor
    Return m.lcReturn
Endfunc

文章评论,共0条
游客请输入验证码
文章分类
最新评论