Issue #6153 has been reported by John Firebaugh.

----------------------------------------
Bug #6153: inconsistent encoding for result of String#<< vs #+
https://bugs.ruby-lang.org/issues/6153

Author: John Firebaugh
Status: Open
Priority: Normal
Assignee: 
Category: 
Target version: 
ruby -v: ruby 1.9.3p125 (2012-02-16 revision 34643) [x86_64-darwin11.3.0]


>> Encoding.compatible?("abc".encode("ASCII-8BIT"), "123".encode("ASCII-8BIT"))
=> #<Encoding:ASCII-8BIT>
>> ("abc".encode("ASCII-8BIT") << "123".encode("US-ASCII")).encoding
=> #<Encoding:ASCII-8BIT>
>> ("abc".encode("ASCII-8BIT").concat "123".encode("US-ASCII")).encoding
=> #<Encoding:ASCII-8BIT>
>> ("abc".encode("ASCII-8BIT") + "123".encode("US-ASCII")).encoding
=> #<Encoding:US-ASCII>

Is there a reason why the last example doesn't return ASCII-8BIT as well?



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