Actions
Bug #9164
closedIO::foreach incorrect work for binary file on windows platform
Description
d2 = "123\n".b + "\x1a\xe8\xba\b".b + "\n789\n".b
File.binwrite('1.txt', d2)
p File.binread('1.txt').each_line.to_a # => ["123\n", "\x1A\xE8\xBA\b\n", "789\n"]
p File.foreach('1.txt').to_a # => ["123\n"]
Encoding.default_external = Encoding::UTF_8
p File.foreach('1.txt').to_a # => ["123\n"]
Encoding.default_external = Encoding::ASCII_8BIT
p File.foreach('1.txt').to_a # => ["123\n"]
run above code on windows, File.foreach.to_a just return 1 row.
run on mac and linux, that's correct, return 3 rows.
Actions
Like0
Like0Like0Like0