Thursday, October 4, 2007

VBScript: URLDecode Function

Function URLDecode(ByVal str)
Dim intI, strChar, strRes
str = Replace(str, "+", " ")
For intI = 1 To Len(str)
strChar = Mid(str, intI, 1)
If strChar = "%" Then
If intI + 2 < Len(str) Then
strRes = strRes & Chr(CLng("&H" & Mid(str, intI+1, 2)))
intI = intI + 2
End If
Else
strRes = strRes & strChar
End If
Next
URLDecode = strRes
End Function

No comments: