1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
|
<%
Function URLDecode(str)
str = Replace(str, "+", " ")
For i = 1 To Len(str)
sT = Mid(str, i, 1)
If sT = "%" Then
If i+2 < Len(str) Then
sR = sR & _
Chr(CLng("&H" & Mid(str, i+1, 2)))
i = i+2
End If
Else
sR = sR & sT
End If
Next
URLDecode = sR
End Function
Function URLEncode(str)
URLEncode = Server.URLEncode(str)
End Function
str1 = "http://www.foo.com/blah.asp?foo=1 & 2 &g=0"
str2 = URLEncode(str1)
str3 = URLDecode(str2)
Response.Write(str1 & "<br>" & str2 & "<br>" & str3)
%> |
Partager