Created
February 18, 2009 19:36
-
-
Save rcarver/66498 to your computer and use it in GitHub Desktop.
The difference between CGI.escape and URI.escape
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
| require 'uri' | |
| require 'cgi' | |
| puts ["i", "i.chr", "URI.escape", "CGI.escape"].collect { |x| x.inspect }.join("\t") | |
| (0..255).each do |i| | |
| chr = i.chr | |
| cgi = CGI.escape(chr) | |
| uri = URI.escape(chr) | |
| puts [i, chr, uri, cgi].collect { |x| x.inspect }.join("\t") if cgi != uri | |
| end |
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
| "i" "i.chr" "URI.escape" "CGI.escape" | |
| 32 " " "%20" "+" | |
| 33 "!" "!" "%21" | |
| 36 "$" "$" "%24" | |
| 38 "&" "&" "%26" | |
| 39 "'" "'" "%27" | |
| 40 "(" "(" "%28" | |
| 41 ")" ")" "%29" | |
| 42 "*" "*" "%2A" | |
| 43 "+" "+" "%2B" | |
| 44 "," "," "%2C" | |
| 47 "/" "/" "%2F" | |
| 58 ":" ":" "%3A" | |
| 59 ";" ";" "%3B" | |
| 61 "=" "=" "%3D" | |
| 63 "?" "?" "%3F" | |
| 64 "@" "@" "%40" | |
| 91 "[" "[" "%5B" | |
| 93 "]" "]" "%5D" | |
| 126 "~" "~" "%7E" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment