Page 1 of 1

Decode URL encoding...?

Posted: Mon Jun 02, 2008 3:52 pm
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...

Posted: Mon Jun 02, 2008 4:27 pm
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

Posted: Mon Jun 02, 2008 8:14 pm
by cormullion
Ah good! I haven't looked inside cgi.lsp much, even though I use it lots...

Thanks!