Created
October 3, 2013 17:11
-
-
Save alanstevens/6813382 to your computer and use it in GitHub Desktop.
Ruby encoding is fun!
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[29] pry(main)> foo = 'a&b*c d' | |
=> "a&b*c d" | |
[30] pry(main)> URI::escape(foo, /[^a-zA-Z0-9\-\.\_\~]/) | |
=> "a%26b%2Ac%20d" | |
[31] pry(main)> uri_val = URI.escape(foo, Regexp.new("[^#{URI::PATTERN::UNRESERVED}]")) | |
=> "a%26b*c%20d" | |
[32] pry(main)> CGI.escape(foo) | |
=> "a%26b%2Ac+d" | |
[33] pry(main)> URI.escape(foo) | |
=> "a&b*c%20d" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You should try [].