close

直接使用

 BankURL = URLDecode(BankURL) 


Function URLDecode(ByVal enStr As String)
        Dim deStr As String
        Dim c, i, v
        deStr = ""
        For i = 1 To Len(enStr)
            c = Mid(enStr, i, 1)
            If c = "%" Then
                v = "&h" + Mid(enStr, i + 1, 2)
                If v < 128 Then
                    deStr = deStr & Chr(v)
                    i = i + 2
                Else
                    If isvalidhex(Mid(enStr, i, 3)) Then
                        If isvalidhex(Mid(enStr, i + 3, 3)) Then
                            v = "&h" + Mid(enStr, i + 1, 2) + Mid(enStr, i + 4, 2)
                            deStr = deStr & Chr(v)
                            i = i + 5
                        Else
                            v = "&h" + Mid(enStr, i + 1, 2) + CStr(Hex(Asc(Mid(enStr, i + 3, 1))))
                            deStr = deStr & Chr(v)
                            i = i + 3
                        End If
                    Else
                        deStr = deStr & c
                    End If
                End If
            Else
                If c = "+" Then
                    deStr = deStr & " "
                Else
                    deStr = deStr & c
                End If
            End If
        Next
        URLDecode = deStr
    End Function


    Function isvalidhex(ByVal str)
        Dim c
        isvalidhex = True
        str = UCase(str)
        If Len(str) <> 3 Then
            isvalidhex = False
            Exit Function
        End If
        If Left(str, 1) <> "%" Then
            isvalidhex = False
            Exit Function
        End If
        c = Mid(str, 2, 1)
        If Not (((c >= "0") And (c <= "9")) Or ((c >= "A") And (c <= "Z"))) Then
            isvalidhex = False
            Exit Function
        End If
        c = Mid(str, 3, 1)
        If Not (((c >= "0") And (c <= "9")) Or ((c >= "A") And (c <= "Z"))) Then
            isvalidhex = False
            Exit Function
        End If
    End Function

arrow
arrow
    全站熱搜
    創作者介紹
    創作者 毛魚 的頭像
    毛魚

    機車,攝影,網頁程式分享

    毛魚 發表在 痞客邦 留言(0) 人氣()