Module: DwcaHunter::Encoding
- Defined in:
- lib/dwca_hunter/encoding.rb
Overview
Encoding module fixes encoding issues with data
Class Method Summary collapse
Class Method Details
.latin1_to_utf8(file_path) ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/dwca_hunter/encoding.rb', line 6 def self.latin1_to_utf8(file_path) new_file = file_path + ".utf_8" puts "Creating #{new_file}" r = File.open(file_path) w = File.open(new_file, "w:utf-8") he = HTMLEntities.new r.each do |l| l = l l = l.encode("UTF-8", "ISO-8859-1", invalid: :replace, replace: "?") l = he.decode(l) w.write l end r.close w.close new_file end |