I'll just use ht:Pack instead, thanks for the pointers though :-)


On Mon, Jan 11, 2010 at 7:36 AM, Alexander Burger <a...@software-lab.de>wrote:

> On Sat, Jan 09, 2010 at 08:28:15PM +0100, Henrik Sarvell wrote:
> > snag I had to solve. I couldn't find a global function so I made my own:
> >
> > (dm urlDecode> (Str)
> >    (pack
> >       (make
> >          (in (list 'echo Str)
> >             (while (char)
> >                (let Char @
> >                   (ifn (= Char "%")
> >                      (unless (= "^J" Char) (link Char))
> >                      (link (char (hex (pack (char) (char))))))))))))
>
> Well, if I see this right, then there is indeed a function, 'ht:Pack':
>
>   (dm urlDecode> (Str)
>      (ht:Pack (chop Str)) )
>
> I would be rather reluctant to start such a heavy machinery like a pipe
> to the external 'echo' program above, just to parse a string. You could
> instead do
>
>   (dm urlDecode> (Str)
>      (setq Str (chop Str))
>      (pack
>         (make
>            (while (pop 'Str)
>               (let Char @
>                  (link
>                     (if (= Char "%")
>                        (char (hex (pack (cut 2 'Str))))
>                        Char ) ) ) ) ) ) )
>
>
> > (in (list 'echo Str)) is a trick I got from Armadillo (originally as a
> way
> > to use (xml) with strings), however it seems like it's attaching a
> newline
> > before end of input so maybe not the best solution here (when using (xml)
> > it's a non issue).
>
> The newline could be suppressed with the '-n' option to echo.
>
>
> > Are there any suggestions on how the above could have been done in a
> better
> > way? Apart from that final newline I like the idea of being able to
> stream a
> > string internally to be able to utilize the input channel functions, in
> this
> > case (char).
>
> Yeah, this is really a deficit in PicoLisp, not being able to use the
> standard 'in' function directly on symbols (strings) :-(
>
> Cheers,
> - Alex
> --
> UNSUBSCRIBE: mailto:picol...@software-lab.de?subject=unsubscribe
>

Reply via email to