Project

General

Profile

Actions

Bug #21763

open

Windows: 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

Added by YO4 (Yoshinao Muramatsu) about 4 hours ago. Updated about 4 hours ago.

Status:
Open
Assignee:
-
Target version:
-
[ruby-core:124025]

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

Also available in: PDF Atom