I\'m trying to encode URLs in Ruby and decode them with Javascript. However, the plus character is giving me weird behavior.
In Ruby:
[Dev]> CGI.e
You might want to look at URI.encode and URI.decode:
require 'uri'
URI.encode('a + b') # => "a%20+%20b"
URI.decode('a%20+%20b') # => "a + b"
An alternate, that I use a lot, is Addressable::URI:
require 'addressable/uri'
Addressable::URI.encode('a + b') #=> "a%20+%20b"
Addressable::URI.unencode('a%20+%20b') #=> "a + b"