From: "YO4 (Yoshinao Muramatsu) via ruby-core" Date: 2025-12-04T11:38:19+00:00 Subject: [ruby-core:124026] [Ruby Bug#21763] Windows: output IO pipe ignores crlf newline conversion specified by set_encoding 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/ ______________________________________________ ruby-core mailing list -- ruby-core@ml.ruby-lang.org To unsubscribe send an email to ruby-core-leave@ml.ruby-lang.org ruby-core info -- https://ml.ruby-lang.org/mailman3/lists/ruby-core.ml.ruby-lang.org/