Topic: rawurlencode in ruby?

I'm looking for a ruby version of rawurlencode. CGI.unescape isn't the same!
in PHP:

results in EWcGtzsvotnBjC07bQT3kIeUFYr2z1YPm4Gwu5RFLsGixBPQ+8d/0nV2h3uyU9MjAwMD
actually the same.

But in Ruby:
>> CGI.unescape("EWcGtzsvotnBjC07bQT3kIeUFYr2z1YPm4Gwu5RFLsGixBPQ+8d/0nV2h3uyU9MjAwMDi")
=> "EWcGtzsvotnBjC07bQT3kIeUFYr2z1YPm4Gwu5RFLsGixBPQ 8d/0nV2h3uyU9MjAwMDi"

Notice the missing + ?

All I could find was a rawurlencode ( … e-stand-up) but I need the decode!
Kind of stuck here.

Re: rawurlencode in ruby?

as usual ... after searching hours for a response I find the answer only 1 minute after posting.

CGI.unescapeHTML should do the trick.

LE: no, that was completely wrong!
Works for some data but not always. after some further digging I found this: … e.markdown

The rawurlencode function in PHP encodes according to the RFC 1738 spec, and uses %20  to encode spaces instead of a plus (+) character. If you want to encode your URLs according to RFC 1738, you'll need to use String#gsub to replace the + character with %20.

Last edited by lcx (2010-02-15 10:25:38)