From: nagachika00@... Date: 2015-02-24T13:48:56+00:00 Subject: [ruby-core:68281] [Ruby trunk - Bug #10893] String#chomp (and chomp!) with a UTF-8 record separator results in Encoding::CompatibilityError Issue #10893 has been updated by Tomoyuki Chikanaga. Backport changed from 2.0.0: UNKNOWN, 2.1: UNKNOWN, 2.2: DONE to 2.0.0: DONTNEED, 2.1: DONTNEED, 2.2: DONE ``` % ruby -ve '$/="\n".encode("UTF-8"); p "abc\r\n".encode("utf-32be").chomp' ruby 2.0.0p598 (2014-11-13 revision 48408) [x86_64-darwin13.4.0] "abc" ``` ``` % ruby -ve '$/="\n".encode("UTF-8"); p "abc\r\n".encode("utf-32be").chomp' ruby 2.1.5p299 (2015-02-19 revision 49651) [x86_64-darwin13.0] "abc" ``` ---------------------------------------- Bug #10893: String#chomp (and chomp!) with a UTF-8 record separator results in Encoding::CompatibilityError https://bugs.ruby-lang.org/issues/10893#change-51639 * Author: Benoit Daloze * Status: Closed * Priority: Normal * Assignee: * ruby -v: ruby 2.3.0dev (2015-02-23 trunk 49693) [x86_64-linux] * Backport: 2.0.0: DONTNEED, 2.1: DONTNEED, 2.2: DONE ---------------------------------------- Reproducing code: $/="\n".encode("UTF-8"); p "abc\r\n".encode("utf-32be").chomp The encode to UTF-8 is to make sure the encoding is consistent across versions, but in recent rubies it is not necessary to trigger the bug. ruby 2.3.0dev (2015-02-23 trunk 49693) [x86_64-linux] -e:1:in `chomp': incompatible character encodings: UTF-32BE and UTF-8 (Encoding::CompatibilityError) from -e:1:in `
' ruby 2.2.0p0 (2014-12-25 revision 49005) [x86_64-linux] -e:1:in `chomp': incompatible character encodings: UTF-32BE and UTF-8 (Encoding::CompatibilityError) from -e:1:in `
' ruby 2.1.3p242 (2014-09-19 revision 47630) [x86_64-linux] "abc" -- https://bugs.ruby-lang.org/