分享

请问VB中URLEncode怎写?

 枫叶cn 2012-11-23
VB post 提交中文信息需要进行Content-Type: application/x-www-form-urlencoded编码。
代码如下:
Public Function URLEncode(ByVal strParameter As String) As String
Dim s As String
Dim I As Integer
Dim intValue As Integer

Dim TmpData() As Byte

    s = ""
    TmpData = StrConv(strParameter, vbFromUnicode)
    For I = 0 To UBound(TmpData)
        intValue = TmpData(I)
        If (intValue >= 48 And intValue <= 57) Or _
            (intValue >= 65 And intValue <= 90) Or _
            (intValue >= 97 And intValue <= 122) Then
            s = s & Chr(intValue)
        ElseIf intValue = 32 Then
            s = s & "+"
        Else
            s = s & "%" & Hex(intValue)
        End If
    Next I
    URLEncode = s

End Function

    本站是提供个人知识管理的网络存储空间,所有内容均由用户发布,不代表本站观点。请注意甄别内容中的联系方式、诱导购买等信息,谨防诈骗。如发现有害或侵权内容,请点击一键举报。
    转藏 分享 献花(0

    0条评论

    发表

    请遵守用户 评论公约

    类似文章 更多