decode query string

sourceuno
Posts: 225
Joined: Mon Apr 09, 2001 3:58 pm

decode query string

Post by sourceuno »

I'm trying to extract a query string variable which is URL encoded. I need to get the query variable from the following URL:

http://www.mysite.com/scripts/texis.exe ... c344436384

I tried to decode the query variable by using the following strfmt function:

<strfmt "%!U" $query>

But I get this result in $ret:

"ford mustang"

I need $ret to be equal to "ford mustang". How can I do this?
User avatar
mark
Site Admin
Posts: 5519
Joined: Tue Apr 25, 2000 6:56 pm

decode query string

Post by mark »

It's probably correct. It's a display issue. Remember that vortex HTML escapes text when displaying it. Use <fmt "%s" $ret> to get it out literally.
User avatar
Kai
Site Admin
Posts: 1272
Joined: Tue Apr 25, 2000 1:27 pm

decode query string

Post by Kai »

Query-string variables are automatically URL-decoded when passed to a Vortex script; all you need to do is look at $query. See the Vortex manual, http://www.thunderstone.com/site/vortexman/node15.html for more on variable initialization.

$query is already URL-decoded, and <fmt "%!U" $query> doesn't do anything further. Those double quotes are part of the query as given in the URL (the %22 characters). When you print the variable, Vortex will then HTML-escape (not URL) the value, as it would with any variable, because the default output mode is HTML. That's why you see the ampersand-quot; instead of the double quote. However, the actual value -- as passed to any function such as <SQL> -- really is double-quote. See http://www.thunderstone.com/site/vortexman/node11.html for info. If you don't want the value escaped when printed, use <send $query>.