Actions
Bug #12989
closedPassing `binmode: true` to `IO.pipe` makes `binmode?` return `true` but encoding is not binary
Description
Here is a sample program:
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.
Files
Actions
Like0
Like0Like0Like0Like0Like0