Issue #5855 has been updated by John Firebaugh.


=begin
> Maybe both of them should be ASCII-8BIT.

I would prefer not, as then String#<< with an Integer ((|i|)) can't be defined as (({self << i.chr(self.encoding)})).

I think it would make much more sense for (({"".encode("US-ASCII") << 128})) and (({128.chr("US-ASCII")})) both to raise RangeError. The current behavior is just weird:

  a = "".encode("US-ASCII") << 128
  b = 128.chr("US-ASCII")
  a == b #=> true
  a.valid_encoding? #=> true
  b.valid_encoding? #=> false

=end

----------------------------------------
Feature #5855: inconsistent treatment of 8 bit characters in US-ASCII
https://bugs.ruby-lang.org/issues/5855

Author: John Firebaugh
Status: Assigned
Priority: Normal
Assignee: Yui NARUSE
Category: 
Target version: 


=begin
Does Ruby allow 8 bit characters (127-255) in a US-ASCII encoded string, or not?

   "\u{80}".encode("US-ASCII")      #=> Encoding::UndefinedConversionError
   0x80.chr("US-ASCII")             #=> "\x80" (US-ASCII encoding)
   "".encode("US-ASCII") << 128     #=> "\x80" (US-ASCII encoding)
   "".encode("US-ASCII") << 128.chr #=> "\x80" (ASCII-8BIT encoding)
=end



-- 
http://redmine.ruby-lang.org