Project

General

Profile

Actions

Bug #20416

closed

IO#read doesn't change buffer encoding unless `maxlen = nil`

Added by andrykonchin (Andrew Konchin) 3 months ago. Updated 24 days ago.

Status:
Closed
Assignee:
-
Target version:
-
[ruby-core:117470]

Description

IO#read(nil, buffer) doesn't change buffer's encoding, but it does when maxlen parameter is specified:

buffer = "".encode(Encoding::ISO_8859_1)
p File.open("test.rb").read(1000, buffer).encoding # => #<Encoding:ISO-8859-1>

buffer = "".encode(Encoding::ISO_8859_1)
p File.open("test.rb").read(nil, buffer).encoding  # => #<Encoding:UTF-8>

I would expect changing buffer encoding in all the cases.

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0Like0Like0