直接使用
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
留言列表