Dim s As String
Dim ch As String
Dim iAscii As Integer
Dim i As Long
For i = 1 To Len(Text)
ch = Mid$(Text, i, 1)
Select Case ch
Case "0" To "9", "a" To "z", "A" To "Z", _
"-", "_", ".", "!", "~", "*", "'", "(", ")"
s = s & ch
Case Else
iAscii = AscW(ch)
If (0 <= iAscii) And (iAscii < 255) Then
s = s & ("%" & Right$("0" & Hex(iAscii), 2))
Else
s = s & ("%u" & Right$("000" & Hex(iAscii), 4))
End If
End Select
Next
Escape = s
End Function
Function Unescape(ByVal Text As String) As String
Dim i As Long
For i = 1 To Len(Text)
If Mid$(Text, i, 2) = "%u" Then Text = Replace$(Text, Mid$(Text, i, 6), ChrW$(AscW(ChrW$("&H" & Mid$(Text, i + 2, 4)))))
If Mid$(Text, i, 1) = "%" Then Text = Replace$(Text, Mid$(Text, i, 3), Chr$(Asc(Chr$("&H" & Mid$(Text, i + 1, 2)))))
Next i
Unescape = Text
End Function