Project

General

Profile

Bug #12989

Updated by nobu (Nobuyoshi Nakada) over 7 years ago

Here is a sample program: 

 ~~~ruby ~~~ 
 Encoding.default_external = Encoding::UTF_8 
 Encoding.default_internal = Encoding::UTF_8 

 reader, writer = IO.pipe(binmode: true) 
 reader.binmode?             # => true 
 reader.external_encoding    # => #<Encoding:UTF-8> 
 writer.binmode?             # => true 
 writer.external_encoding    # => #<Encoding:UTF-8> 

 reader, writer = IO.pipe 
 reader.binmode 
 writer.binmode 

 reader.binmode?             # => true 
 reader.external_encoding    # => #<Encoding:ASCII-8BIT> 
 writer.binmode?             # => true 
 writer.external_encoding    # => #<Encoding:ASCII-8BIT> 
 ~~~ 

 I think that passing `binmode: true` to `IO.pipe` should behave the same way as calling `binmode` on each file.    Today, passing `binmode: true` to IO.pipe puts the files in a strange state: they are binary and not binary. 

 I've attached a patch to fix the problem.

Back