Actions
Bug #21763
openWindows: output IO pipe ignores crlf newline conversion specified by set_encoding
Bug #21763:
Windows: output IO pipe ignores crlf newline conversion specified by set_encoding
Description
On Windows, output pipes have no crlf conversion applied by default except for stdout/stderr, also it ignore set_encoding(crlf_newline: true).
> ruby -e "IO.pipe { |r,w| w.set_encoding('ascii-8bit', crlf_newline: true); w.puts ?a; w.close; p r.binmode.read }"
"a\n" # => "a\r\n" is expected
On other platforms, this is effective.
$ ruby -e "IO.pipe { |r,w| w.set_encoding('ascii-8bit', crlf_newline: true); w.puts ?a; w.close; p r.binmode.read }"
"a\r\n"
This occurs only when using the C runtime _write() for newline conversion. It works correctly when performing CRLF conversion using encoding conversion.
> ruby -e "IO.pipe { |r,w| w.set_encoding('us-ascii', crlf_newline: true); w.puts ?a; w.close; p r.binmode.read }"
"a\r\n"
This also affects an IO duped from stdout.
> ruby -e "STDOUT.puts ?a; STDOUT.dup.puts ?b" | ruby -e "p STDIN.binmode.read"
"a\r\nb\n" # => "b\n" seems to wrong
Actions