Skip to content

Commit

Permalink
Revert "CSV.open: detect BOM by default"
Browse files Browse the repository at this point in the history
This reverts commit b706d91.
  • Loading branch information
kou committed Jun 5, 2024
1 parent a727f84 commit d66d518
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 18 deletions.
9 changes: 1 addition & 8 deletions lib/csv.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1581,14 +1581,7 @@ def generate_lines(rows, **options)
def open(filename, mode="r", **options)
# wrap a File opened with the remaining +args+ with no newline
# decorator
file_opts = {}
have_encoding_options = (options.key?(:encoding) or
options.key?(:external_encoding) or
mode.include?(":"))
if not have_encoding_options and Encoding.default_external == Encoding::UTF_8
file_opts[:encoding] = "bom|utf-8"
end
file_opts.merge!(options)
file_opts = options.dup
unless file_opts.key?(:newline)
file_opts[:universal_newline] ||= false
end
Expand Down
10 changes: 0 additions & 10 deletions test/csv/interface/test_read.rb
Original file line number Diff line number Diff line change
Expand Up @@ -215,16 +215,6 @@ def test_open_with_newline
end
end

def test_open_with_bom
csv_data = @input.read
bom = "\ufeff" # U+FEFF ZERO WIDTH NO-BREAK SPACE
File.binwrite(@input.path, "#{bom}#{csv_data}")
@input.rewind
CSV.open(@input.path, col_sep: "\t") do |csv|
assert_equal(@rows, csv.to_a)
end
end

def test_parse
assert_equal(@rows,
CSV.parse(@data, col_sep: "\t", row_sep: "\r\n"))
Expand Down

0 comments on commit d66d518

Please sign in to comment.