Created
September 2, 2011 07:34
-
-
Save pwim/1188099 to your computer and use it in GitHub Desktop.
Trying different encodings under Ruby 1.9
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
escaped = CGI.unescape(query) | |
return escaped if escaped.valid_encoding? | |
%w[EUC-JP Shift_JIS].each do |encoding| | |
s = escaped.force_encoding(encoding) | |
return s.encode("UTF-8") if s.valid_encoding? | |
end | |
escaped |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment