From: Marc-Andre Lafortune Date: 2010-04-10T06:54:05+09:00 Subject: [ruby-core:29401] Re: URI.(un)escape deprecated? Hi, Imagine I want to display a url to the user in a human readable format (say like the status bar of the browser when a user hovers over a link). Ruby should have a nice "unescape" for that, and the reverse "escape" too. These methods should convert "http://example.com/?name=Marc%20Andr%C3%A9+42" to "http://example.com/?name=Marc Andr�+42" and back (exactly what Chrome does) As the code below shows, the only correct escaping is URI.escape. The only correct unescaping is WEBrick::HTTPUtils.unescape and URI.unescape. Note that WEBrick currently raises an error when escaping... So unless there is another sensible way to go from URL to human readable form and back, I recommend not deprecating URI.{un}escape rubydev -rcgi -ruri -rwebrick/httputils -rerb -e ' # encoding: utf-8 s="http://example.com/?name=Marc Andr�+42" puts [ "escape:", ERB::Util.url_encode(s), CGI.escape(s), URI.encode_www_form_component(s), (WEBrick::HTTPUtils.escape_form(s) rescue "fails"), (WEBrick::HTTPUtils.escape(s) rescue "fails"), URI.escape(s), ] s="http://example.com/?name=Marc%20Andr%C3%A9+42" puts [ "unescape:", # no equivalent in ERB??, CGI.unescape(s), URI.decode_www_form_component(s), WEBrick::HTTPUtils.unescape_form(s), WEBrick::HTTPUtils.unescape(s), URI.unescape(s), ] '