From: "YO4 (Yoshinao Muramatsu) via ruby-core" Date: 2025-11-17T13:20:42+00:00 Subject: [ruby-core:123829] [Ruby Bug#21691] On Windows some of binary read functions of IO are not functional Issue #21691 has been reported by YO4 (Yoshinao Muramatsu). ---------------------------------------- Bug #21691: On Windows some of binary read functions of IO are not functional https://bugs.ruby-lang.org/issues/21691 * Author: YO4 (Yoshinao Muramatsu) * Status: Open * Backport: 3.2: UNKNOWN, 3.3: UNKNOWN, 3.4: UNKNOWN ---------------------------------------- When using the binary read method of IO on a file containing ���\r\n���, it should read ���\r���, but some methods do not function correctly on Windows. ```ruby File.binwrite("crlf.txt", "\r\n") methods = { readn: proc { |f| f.read(1) }, getbyte: proc { |f| f.getbyte.chr }, readbyte: proc { |f| f.readbyte.chr }, readpartial: proc { |f| f.readpartial(1) }, read_nonblock: proc { |f| f.read_nonblock(1) }, sysread: proc { |f| f.sysread(1) }, pread: proc { |f| f.pread(1, 0) }, } def test(mode, name, method) open("crlf.txt", "r") do |f| p [mode, name, method.call(f)] end end methods.each { |k, v| test("r", k, v) } methods.each { |k, v| test("rt", k, v) } ``` results: ```ruby ["r", :readn, "\r"] ["r", :getbyte, "\n"] # => shold be "\r" ["r", :readbyte, "\n"] # => shold be "\r" ["r", :readpartial, "\n"] # => shold be "\r" ["r", :read_nonblock, "\n"] # => shold be "\r" ["r", :sysread, "\n"] # => shold be "\r" ["r", :pread, "\r"] ["rt", :readn, "\r"] ["rt", :getbyte, "\n"] # => shold be "\r" ["rt", :readbyte, "\n"] # => shold be "\r" ["rt", :readpartial, "\n"] # => shold be "\r" ["rt", :read_nonblock, "\n"] # => shold be "\r" ["rt", :sysread, "\n"] # => shold be "\r" ["rt", :pread, "\r"] ``` On Ubuntu in WSL, all returns are ���\r���. -- 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/