Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Decode an encoded url server side

Status
Not open for further replies.

link9

Programmer
Nov 28, 2000
3,387
US
Hello all --

Found this function. It'll do the same thing as the client side javaScript function, unescape().

enjoy. :)
Code:
    function DecodeURLStr(sStr) 'Decodes an encoded QueryString (all URL Entity equivs. will be converted)
    Dim aChars, aANSICodes
    Dim sChars, sANSICodes
    Dim sOutput
    sChars = &quot; ,',!,#,$,%,&,(,),/,:,;,[,\,],^,`,{,|,},+,<,=,>&quot;
    sANSICodes = &quot;+,%27,%21,%23,%24,%25,%26,%28,%29,%2F,%3A,%3B,%5B,%5C,%5D,%5E,%60,%7B,%7C,%7D,%2B,%3C,%3D,%3E&quot;
    aChars = Split(sChars, &quot;,&quot;, -1, 1)
    aANSICodes = Split(sANSICodes, &quot;,&quot;, -1, 1)
    'Debug
    'Response.Write (&quot;URL Decoding Array's&quot; 
    '     & &quot;<BR>&quot;)
    For i = 0 To Ubound(aChars) Step 1
    	'Debug
    	'Response.Write (&quot;Char=&quot; & aChars(i) & &quot; : ANSICode=&quot; & aANSICodes(i) & &quot;<BR>&quot;)
    	if (InStr(1, sStr, aANSICodes(i), vbTextCompare) <> 0) Then 
    		sStr = (Replace(sStr, aANSICodes(i), aChars(i), 1, -1, vbTextCompare))
    	End if
    Next
    DecodeURLStr = sStr
    End function
penny1.gif
penny1.gif
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top