Hi is there an equivalent ruby method to JavaScript encodeURIComponent
method? i am using the URI.unescape(str)
but it recognizes the "£"
(after encodeURIComponent
it becomes "%C2%A3"
) as a "?"
sign. any solution's? thanks
views:
88answers:
3lets say i have a str = "£" i use encodeURIComponent(str) in javascript, but when i use URI.unescape(str) in ruby and that string comes back as a str = "?". so there are differences.
Mo
2010-05-18 14:59:23
lets say i have a str = "£" i use encodeURIComponent(str) in javascript, but when i use URI.unescape(str) in ruby and that string comes back as a str = "?". so there are differences
Mo
2010-05-18 15:02:46
A:
CGI.escape
should escape correctly, except that spaces are escaped as +
.
Note that URI.escape
has been deprecated in Ruby 1.9.2...
There is a long discussion on ruby-core for those interested.
Marc-André Lafortune
2010-05-18 16:17:30