[ruby-core:124025] [Ruby Bug#21763] Windows: output IO pipe ignores crlf newline conversion specified by set_encoding
Issue #21763 has been reported by YO4 (Yoshinao Muramatsu). ---------------------------------------- Bug #21763: Windows: output IO pipe ignores crlf newline conversion specified by set_encoding https://bugs.ruby-lang.org/issues/21763 * Author: YO4 (Yoshinao Muramatsu) * Status: Open * Backport: 3.2: UNKNOWN, 3.3: UNKNOWN, 3.4: UNKNOWN ---------------------------------------- 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
--
https://bugs.ruby-lang.org/
Issue #21763 has been updated by YO4 (Yoshinao Muramatsu). I made PR [#15405](https://github.com/ruby/ruby/pull/15405) ---------------------------------------- Bug #21763: Windows: output IO pipe ignores crlf newline conversion specified by set_encoding https://bugs.ruby-lang.org/issues/21763#change-115457 * Author: YO4 (Yoshinao Muramatsu) * Status: Open * Backport: 3.2: UNKNOWN, 3.3: UNKNOWN, 3.4: UNKNOWN ---------------------------------------- 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
--
https://bugs.ruby-lang.org/
Issue #21763 has been updated by hsbt (Hiroshi SHIBATA). Status changed from Open to Assigned Assignee set to windows ---------------------------------------- Bug #21763: Windows: output IO pipe ignores crlf newline conversion specified by set_encoding https://bugs.ruby-lang.org/issues/21763#change-116001 * Author: YO4 (Yoshinao Muramatsu) * Status: Assigned * Assignee: windows * Backport: 3.2: UNKNOWN, 3.3: UNKNOWN, 3.4: UNKNOWN ---------------------------------------- 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
--
https://bugs.ruby-lang.org/
participants (2)
-
hsbt (Hiroshi SHIBATA) -
YO4 (Yoshinao Muramatsu)