Decode URL encoding...?

Notices and updates
Locked
cormullion
Posts: 2038
Joined: Tue Nov 29, 2005 8:28 pm
Location: latiitude 50N longitude 3W
Contact:

Decode URL encoding...?

Post by cormullion »

Is there an easy way in newLISP to decode this sort of encoding?

Code: Select all

pish+and+tush%0D%0A%0D%0Aflannel+and+soap%0D%0A%0D%0A%3CI+don%27t+think+this+blog+is+very+good
I can handle replacing the + signs, but all those % codes need converting too...

Lutz
Posts: 5289
Joined: Thu Sep 26, 2002 4:45 pm
Location: Pasadena, California
Contact:

Post by Lutz »

From modules/cgi.lsp:

Code: Select all

(define (url-translate str)
   (replace "+" str " ")
   (replace "%([0-9A-F][0-9A-F])" str (char (int (append "0x" $1))) 1))
See also here: http://newlisp.org/code/modules/cgi.lsp.html

cormullion
Posts: 2038
Joined: Tue Nov 29, 2005 8:28 pm
Location: latiitude 50N longitude 3W
Contact:

Post by cormullion »

Ah good! I haven't looked inside cgi.lsp much, even though I use it lots...

Thanks!

Locked