[#70257] [Ruby trunk - Feature #11420] [Open] Introduce ID key table into MRI — ko1@...

Issue #11420 has been reported by Koichi Sasada.

11 messages 2015/08/06

[ruby-core:70384] [Ruby trunk - Bug #11324] Encoding to a String's own encoding with some options fails

From: nagachika00@...
Date: 2015-08-14 07:42:34 UTC
List: ruby-core #70384
Issue #11324 has been updated by Tomoyuki Chikanaga.

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

Backported into `ruby_2_2` branch at r51573.

----------------------------------------
Bug #11324: Encoding to a String's own encoding with some options fails
https://bugs.ruby-lang.org/issues/11324#change-53787

* Author: Sakuro OZAWA
* Status: Closed
* Priority: Normal
* Assignee: 
* ruby -v: ruby 2.2.2p95 (2015-04-13 revision 50295) [x86_64-darwin14]
* Backport: 2.0.0: REQUIRED, 2.1: REQUIRED, 2.2: DONE
----------------------------------------
To encode a `String` instance to its own encoding seems to be a bad idea, but following result looks strange:

```ruby
s = "A\nB\r\nC".force_encoding('US-ASCII')
#=> "A\nB\r\nC"
s.encode('US-ASCII')
#=> "A\nB\r\nC"
s.encode('US-ASCII', universal_newline: true)
#=> "A\nB\nC"
s.encode('US-ASCII', universal_newline: true, undef: :replace)
#=> "A\nB\nC"
s.encode('US-ASCII', universal_newline: true, undef: :replace, replace: '')
# Encoding::ConverterNotFoundError: code converter not found (universal_newline)
```

Only when all of these three options are fed, `String#encode` fails and provided message shows unclear encoding name.





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

In This Thread

Prev Next