<% Function Urlencode (STRINPUT) DIM STROUTPUT DIM INTASCII DIM I for i = 1 To Len (Strinput) INTASCII = ASC (MID (STRINPUT, I, 1)) IF ((INTASCII <58) AND (INTASCII> 47)) OR ((INTASCII> 64)) OR (INTASCIii <123) And (intASCIi> 96)) Then stroutPut = stroutput & chr (intASCII) Else if Intascii <16 Then stroutput = stroutput & "% 0" & TRIM (Hex (intAscii)) else strOutput = strOutput & "%" & Trim (Hex (intAscii)) end if End If Next URLEncode = strOutput End Function 'response.Write (URLEncode ( "aa.asp? id = 1")) Function URLDecode (ENSTR) 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)) THE 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))))))) Str = destr & chr (v) i = i 3 end if Else deStr = destr = " " 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 dam 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> = "a") AND (c <= "z"))) ) THEN isvalidHex = false: exit function c = MID (STR, 3, 1) IF NOT (((c> = "0") AND (c <= "9")) OR ((c> = "a") And (c <= "z"))) The isvalidHex = false: exit function end function'Response.write ("
") 'response.write (UrLeNCode ("aa.asp? id = 1") )))%>