6

I want to encode an URL parameter with Ruby. The URL parameter not encoded is like this:

index.php?hash=tlNmgzWNFelvIH1o9ZAWFifpB3RwZOh6DCt5OdIfJCWLo9iZSRONWk1D1rEnSxUp|hi8JcsAHkznPkDFfaS1+xw==

Then I want to decode it from PHP!

I tried ruby:

ERB::Util::url_encode(param)

And then in Php urldecode($param); does not seem to work!

addex03
  • 197
  • 1
  • 2
  • 12

1 Answers1

16

Use CGI::escape on rubyside.

http://ruby-doc.org/stdlib-1.9.3/libdoc/cgi/rdoc/CGI.html#method-c-escape

url_encoded_string = CGI::escape("'Stop!' said Fred")
   # => "%27Stop%21%27+said+Fred"
Jeff Atwood
  • 63,320
  • 48
  • 150
  • 153
pdu
  • 10,295
  • 4
  • 58
  • 95