From: cremno@...
Date: 2018-06-29T17:30:55+00:00
Subject: [ruby-core:87695] [Ruby trunk Bug#14863] Array#join with empty array returns empty string always in US-ASCII encoding

Issue #14863 has been updated by cremno (cremno phobia).


I also believe the current behavior makes sense. It won't cause the `invalid byte sequence in UTF-8` issue. The US-ASCII character set is THE subset (see BINARY which is actually called ASCII-8BIT). Sure the characters are sometimes encoded differently (e.g. UTF-32BE uses 4 bytes) but US-ASCII is fully compatible to UTF-8. Especially in this case as an empty string doesn't contain any characters/byte sequences.

Meanwhile your proposal isn't radical enough to make sense to me: what about `nil.to_s`? Or the non-empty `65.chr`?

----------------------------------------
Bug #14863: Array#join with empty array returns empty string always in US-ASCII encoding
https://bugs.ruby-lang.org/issues/14863#change-72719

* Author: xsimov (Xavier Sim��)
* Status: Feedback
* Priority: Normal
* Assignee: 
* Target version: 
* ruby -v: 2.4.2
* Backport: 2.3: UNKNOWN, 2.4: UNKNOWN, 2.5: UNKNOWN
----------------------------------------
Calling
~~~
irb(main):001:0> [].join.encoding
=> #<Encoding:US-ASCII>
~~~ 
returns an empty string and that empty string is always in US-ASCII encoding.

The expected result is that the returned empty string would be in UTF-8 since it seems to be the default for Ruby strings since 2.0.





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

Unsubscribe: <mailto:ruby-core-request@ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>