2010/4/11 Marc-Andre Lafortune <ruby-core-mailing-list / marc-andre.ca>:
>
> In most if not all browsers, if I type in
> "http://example.com/?name=Marc Andr42", this string will be
> URI.escaped and used for http request.
>
> So any application that requests a URL from its user needs URI.escape.

% ruby -ruri -e 'p URI.escape("http://example.com/?name=Marc Andr42")'
"http://example.com/?name=Marc%20Andr%C3%A9+42"

Assuming that the web application interprets the query string according to
application/x-www-form-urlencoded, the value is "Marc Andr42".
The plus symbol is replaced by space.

Is it desired behavior?

% ruby -ruri -e 'p URI.escape("http://example.com/#foo")'
"http://example.com/%23foo"

I think the user intend that #foo means a fragment but
URI.escape replaces it to a path segment.

% ruby -ruri -e 'p URI.escape("http://example.com/%7Eakr/")'
"http://example.com/%257Eakr/"

I think the user intend that http://example.org/~akr/ but
URI.escape replaces it to a different resource.

% ruby -ruri -e 'p URI.unescape("http://example.com/%23foo")'
"http://example.com/#foo"

The actual URI contains the path segment %23foo but
URI.unescape replaces it to a fragment.

URI.escape and URI.unescape is not what you want.

> I will argue that we must find a better solution that deprecating a
> useful method before any replacement is available.

The methods are not useful for your purpose.

It may be good to have such methods in URI.
But URI.escape and URI.unescape is too ambiguos name for that.

People tend to think URI.escape is usable for building URI components
which is different to the purpose.
Try code search:
http://www.google.com/codesearch?q=URI.escape+lang%3Aruby
-- 
Tanaka Akira