Function unescape(Byval s$) As String
' Given a string that contains "%" codes for spaces and other punctuation, as they would appear in a URL, this function converts them back to the original string using the Uchr$ function.
Dim pos%, lpos%, ccod$, result$
lpos = 1
pos = Instr(s, "%")
Do Until pos = 0
' the characters up until the % are ones we can just add to the string.
If pos > lpos Then result = result & Mid$(s, lpos, pos-lpos)
ccod = Mid$(s, pos+1, 2) ' get the hex code of the character
If ccod Like "[a-fA-F0-9][a-fA-F0-9]" Then
result = result & Uchr$(Cint("&H" & ccod))
lpos = pos + 3
Else
result = result & "%"
lpos = pos + 1
End If
pos = Instr(lpos, s, "%")
Loop
unescape = result & Mid$(s, lpos)
End Function