Function UrlDecode(encodestr)
Dim NewStr
NewStr=""
havechar=false
lastchar=""
For i=1 To Len(encodestr)
char_c=Mid(encodestr,i,1)
If char_c = "+" Then
newstr=newstr & " "
Elseif char_c="%" then
next_1_c=Mid(encodestr,i+1,2)
next_1_num=CInt("&H" & next_1_c)
If havechar Then
havechar=false
newstr=newstr & chr(Cint("&H" & lastchar & next_1_c))
Else
If Abs(next_1_num)<=127 Then
newstr=newstr & chr(next_1_num)
Else
havechar=true
lastchar=next_1_c
End If
End If
i=i+2
Else
newstr=newstr & char_c
End If
Next
urldecode=newstr
End function
|