Issue #19235 has been updated by andrykonchin (Andrew Konchin).
Yeah, so this issue is a duplicate. My bad (.
So this issue probably should be closed.
----------------------------------------
Bug #19235: StringIO.new(encoding: "ext_enc:int_enc") doesn't set external
encoding
https://bugs.ruby-lang.org/issues/19235#change-101533
* Author: andrykonchin (Andrew Konchin)
* Status: Open
* Priority: Normal
* ruby -v: 3.1.2
* Backport: 2.7: UNKNOWN, 3.0: UNKNOWN, 3.1: UNKNOWN
----------------------------------------
I noticed a divergence between IO `:encoding` option documentation and StringIO's
behaviour:
```ruby
io = StringIO.new('', 'w', encoding: 'utf-8:ISO-8859-1')
io.external_encoding # => #<Encoding:ISO-8859-1>
```
According to the
[
documentation](https://ruby-doc.org/3.1.3/IO.html#class-IO-label-Open+Optio…:
```
:encoding: Specifies external and internal encodings as 'extern:intern'.
```
The IO class behaves in expected way:
```ruby
f = File.open("test.txt", 'w', encoding: 'UTF-8:ISO-8859-1')
f.external_encoding # => #<Encoding:UTF-8>
```
--
https://bugs.ruby-lang.org/