newLISP Fan Club

Forum => newLISP newS => Topic started by: cormullion on June 02, 2008, 08:52:45 AM

Title: Decode URL encoding...?
Post by: cormullion on June 02, 2008, 08:52:45 AM
Is there an easy way in newLISP to decode this sort of encoding?


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...
Title:
Post by: Lutz on June 02, 2008, 09:27:22 AM
From modules/cgi.lsp:



(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
Title:
Post by: cormullion on June 02, 2008, 01:14:17 PM
Ah good! I haven't looked inside cgi.lsp much, even though I use it lots...



Thanks!