[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: string splitting

From: Andy Wingo
Subject: Re: string splitting
Date: Tue, 21 Feb 2012 10:53:37 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.3 (gnu/linux)

On Mon 20 Feb 2012 19:51, Catonano <address@hidden> writes:

> I'd love to split a url string. Is there a function I am supposed to use ? In 
> which module ?
> that is
> "...blah/blah?param1=1234&amp;param2=5678"

Use (web uri).  Specifically string->uri and uri-query.

Once you have the query string, you can pick apart the pieces with
something like this:

  (define* (parse-www-form-urlencoded str #:optional (charset "utf-8"))
     (lambda (piece)
       (let ((equals (string-index piece #\=)))
         (if equals
             (cons (uri-decode (substring piece 0 equals) #:encoding charset)
                   (uri-decode (substring piece (1+ equals)) #:encoding 
             (cons (uri-decode piece #:encoding charset) ""))))
     (string-split str #\&)))


reply via email to

[Prev in Thread] Current Thread [Next in Thread]