Skip to content

Instantly share code, notes, and snippets.

@tjchambers
Forked from romeuhcf/csv_with_bom.rb
Created November 14, 2021 00:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tjchambers/68830208435211855fe9f424ce8de422 to your computer and use it in GitHub Desktop.
Save tjchambers/68830208435211855fe9f424ce8de422 to your computer and use it in GitHub Desktop.
Ruby 2.5 support for opening csv with bom|utf-8
class CSV
def self.open(file, options={}, &block)
encoding = options.delete(:encoding)
File.open(file, "r:#{encoding}") do |fd|
yield CSV.new(fd, options)
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment