Server. urlencode (STR)
Decryption code
<%
Function urldecode (enstr) 'url decoding function
Dim destr
Dim C, I, V
Destr = ""
For I = 1 to Len (enstr)
C = mid (enstr, I, 1)
If C = "%" then
V = eval ("& H" + mid (enstr, I + 1, 2 ))
If v <128 then
Destr = destr & CHR (V)
I = I + 2
Else
If isvalidhex (mid (enstr, I, 3) then
If isvalidhex (mid (enstr, I + 3, 3) then
V = eval ("& H" + mid (enstr, I + 1, 2) + mid (enstr, I + 4, 2 ))
Destr = destr & CHR (V)
I = I + 5
Else
V = eval ("& H" + mid (enstr, I + 1, 2) + CSTR (hex (ASC (mid (enstr, I + 3, 1 )))))
Destr = destr & CHR (V)
I = I + 3
End if
Else
Destr = destr & C
End if
End if
Else
If C = "+" then
Destr = destr &""
Else
Destr = destr & C
End if
End if
Next
Urldecode = destr
End Function
Function isvalidhex (STR)
Isvalidhex = true
STR = ucase (STR)
If Len (STR) <> 3 then isvalidhex = false: Exit Function
If left (STR, 1) <> "%" then isvalidhex = false: Exit Function
C = mid (STR, 2, 1)
If not (C> = "0") and (C <= "9") or (C> = "") and (C <= "Z") Then isvalidhex = false: Exit Function
C = mid (STR, 3,1)
If not (C> = "0") and (C <= "9") or (C> = "") and (C <= "Z") Then isvalidhex = false: Exit Function
End Function
%>