[ruby-core:68258] [Ruby trunk - Bug #10893] [Open] String#chomp (and chomp!) with a UTF-8 record separator results in Encoding::CompatibilityError

From: eregontp@...
Date: 2015-02-23 13:53:20 UTC
List: ruby-core #68258
Issue #10893 has been reported by Benoit Daloze.

----------------------------------------
Bug #10893: String#chomp (and chomp!) with a UTF-8 record separator results in Encoding::CompatibilityError
https://bugs.ruby-lang.org/issues/10893

* Author: Benoit Daloze
* Status: Open
* Priority: Normal
* Assignee: 
* ruby -v: ruby 2.3.0dev (2015-02-23 trunk 49693) [x86_64-linux]
* Backport: 2.0.0: UNKNOWN, 2.1: UNKNOWN, 2.2: REQUIRED
----------------------------------------
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 `<main>'


    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 `<main>'

    ruby 2.1.3p242 (2014-09-19 revision 47630) [x86_64-linux]
    "abc"




-- 
https://bugs.ruby-lang.org/

In This Thread

Prev Next