Project

General

Profile

Bug #19235

Updated by andrykonchin (Andrew Konchin) about 2 years ago

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+Options): 
 ``` 
 :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> 
 ```

Back