Project

General

Profile

Actions

Bug #10893

closed

String#chomp (and chomp!) with a UTF-8 record separator results in Encoding::CompatibilityError

Added by Eregon (Benoit Daloze) about 9 years ago. Updated about 9 years ago.

Status:
Closed
Assignee:
-
Target version:
-
ruby -v:
ruby 2.3.0dev (2015-02-23 trunk 49693) [x86_64-linux]
[ruby-core:68258]

Description

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"
Actions

Also available in: Atom PDF

Like0
Like0Like0Like0