diff options
author | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2014-02-10 14:46:36 -0200 |
---|---|---|
committer | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2014-02-10 14:46:36 -0200 |
commit | e063dbc602796c1dcc1d657cefe31d84e45d609f (patch) | |
tree | 333ea0c8c4c567b7d2ec789d4c16ca0bc866104e /activesupport | |
parent | 3b868cc99d4e417ac2090529ba41c4918454913d (diff) | |
parent | ae28e4beb3d9b395ee269999111b6598802da63f (diff) | |
download | rails-e063dbc602796c1dcc1d657cefe31d84e45d609f.tar.gz rails-e063dbc602796c1dcc1d657cefe31d84e45d609f.tar.bz2 rails-e063dbc602796c1dcc1d657cefe31d84e45d609f.zip |
Merge pull request #13919 from jcoyne/fix_jruby_encoding
Fix tidy_bytes for JRuby
Diffstat (limited to 'activesupport')
-rw-r--r-- | activesupport/CHANGELOG.md | 7 | ||||
-rw-r--r-- | activesupport/lib/active_support/multibyte/unicode.rb | 6 |
2 files changed, 10 insertions, 3 deletions
diff --git a/activesupport/CHANGELOG.md b/activesupport/CHANGELOG.md index 9a62bd5a77..43bfeff079 100644 --- a/activesupport/CHANGELOG.md +++ b/activesupport/CHANGELOG.md @@ -1,3 +1,10 @@ +* Fix the implementation of Multibyte::Unicode.tidy_bytes for JRuby + + The existing implementation caused JRuby to raise the error: + `Encoding::ConverterNotFoundError: code converter not found (UTF-8 to UTF8-MAC)` + + *Justin Coyne* + * Fix `to_param` behavior when there are nested empty hashes. Before: diff --git a/activesupport/lib/active_support/multibyte/unicode.rb b/activesupport/lib/active_support/multibyte/unicode.rb index 7e518d8c39..ea3cdcd024 100644 --- a/activesupport/lib/active_support/multibyte/unicode.rb +++ b/activesupport/lib/active_support/multibyte/unicode.rb @@ -233,16 +233,16 @@ module ActiveSupport # We're going to 'transcode' bytes from UTF-8 when possible, then fall back to # CP1252 when we get errors. The final string will be 'converted' back to UTF-8 # before returning. - reader = Encoding::Converter.new(Encoding::UTF_8, Encoding::UTF_8_MAC) + reader = Encoding::Converter.new(Encoding::UTF_8, Encoding::UTF_16LE) source = string.dup - out = ''.force_encoding(Encoding::UTF_8_MAC) + out = ''.force_encoding(Encoding::UTF_16LE) loop do reader.primitive_convert(source, out) _, _, _, error_bytes, _ = reader.primitive_errinfo break if error_bytes.nil? - out << error_bytes.encode(Encoding::UTF_8_MAC, Encoding::Windows_1252, invalid: :replace, undef: :replace) + out << error_bytes.encode(Encoding::UTF_16LE, Encoding::Windows_1252, invalid: :replace, undef: :replace) end reader.finish |