From: "byroot (Jean Boussier) via ruby-core" Date: 2024-06-04T07:16:01+00:00 Subject: [ruby-core:118166] [Ruby master Bug#20416] IO#read doesn't preserve buffer encoding if `maxlen = nil` Issue #20416 has been updated by byroot (Jean Boussier). Yeah, I don't think it's a bug. @nobu should we close? ---------------------------------------- Bug #20416: IO#read doesn't preserve buffer encoding if `maxlen = nil` https://bugs.ruby-lang.org/issues/20416#change-108607 * Author: andrykonchin (Andrew Konchin) * Status: Open * ruby -v: 3.3.0 * Backport: 3.0: UNKNOWN, 3.1: UNKNOWN, 3.2: UNKNOWN, 3.3: UNKNOWN ---------------------------------------- `IO#read(nil, buffer)` doesn't change buffer's encoding, but it does when `maxlen` parameter is specified: ```ruby buffer = "".encode(Encoding::ISO_8859_1) p File.open("test.rb").read(1000, buffer).encoding # => # buffer = "".encode(Encoding::ISO_8859_1) p File.open("test.rb").read(nil, buffer).encoding # => # ``` I would expect changing buffer encoding in all the cases. -- 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/postorius/lists/ruby-core.ml.ruby-lang.org/