Project

General

Profile

Actions

Bug #16997

open

IO#gets converts some \r\n to \n with universal_newline: false

Added by scivola20 (sciv ola) over 4 years ago. Updated about 4 years ago.

Status:
Open
Assignee:
-
Target version:
-
ruby -v:
ruby 2.7.1p83 (2020-03-31 revision a0c7c23c9c) [x86_64-darwin17]
[ruby-core:98989]

Description

Reproduction code:

IO.binwrite "t.csv", ("a" * 100 + "\r\n") * 100
File.open("t.csv", encoding: "BOM|UTF-8", universal_newline: false) do |input|
  p input.gets(nil, 32 * 1024) # => "a...a\n...\na...a\r\n...\r\n"
end

It causes MalformedCSVError at opening CSV file with `encoding: "BOM|UTF-8":
https://github.com/ruby/csv/issues/147

Actions

Also available in: Atom PDF

Like0
Like0