[REBOL] Re: to-url
From: tim:johnsons-web at: 5-Jan-2003 18:36
* Carl Read <[carl--cybercraft--co--nz]> [030105 18:19]:
> On 06-Jan-03, Tim Johnson wrote:
> > Hello :
> > I have some questions about to-url here:
> > supose I want to create a query-string in a url
> > that has letters like "?=&" inside of
> > the values.
> >>> to-url "Father & sons"
> > == Father & sons
> > ;yikes, shouldn't we get Father %26 son ('&' is hex 26, right?)
> > ; decoding this will give incorrect results, I think...
> > Comments and suggestions welcome
> I just searched google for "a & b" to see how it'd make its URL, and
> this is what it returned...
> My guess would be that you'd convert to %26 if it's part of some text,
> but leave as-is if it's for breaking up the query. (A guess mind -
> others here will know the rules I'm sure.)
Great minds run in the same gutter! It would seem that rebol's
native funcs aren't taking this into consideration.
; I just churned this out. Hopefully someone has a better
; solution, if not, pointers are welcome to docs on
; other chars to be escaped.
encode: [#"%" "%25" #"&" "%26" #"=" "%3D" #" " " "]
new-str: make string! (length? str) * 2 ;oh, just an estimate
repeat char str[
either found: select encode char
[append new-str found]
[append new-str char]
> Carl Read
> To unsubscribe from this list, please send an email to
> [rebol-request--rebol--com] with "unsubscribe" in the
> subject, without the quotes.
Tim Johnson <[tim--johnsons-web--com]>