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

From: naruse@...
Date: 2015-02-24 07:40:47 UTC
List: ruby-core #68278
Issue #10893 has been updated by Yui NARUSE.

Backport changed from 2.0.0: UNKNOWN, 2.1: UNKNOWN, 2.2: REQUIRED to 2.0.0: UNKNOWN, 2.1: UNKNOWN, 2.2: DONE

ruby_2_2 r49718 merged revision(s) 49706.

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

* 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: UNKNOWN, 2.1: UNKNOWN, 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 `<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