Skip to content

Instantly share code, notes, and snippets.

@agarie
Created December 18, 2013 03:47
Show Gist options
  • Save agarie/8016988 to your computer and use it in GitHub Desktop.
Save agarie/8016988 to your computer and use it in GitHub Desktop.
Fixes issues when dealing with ISO-8859-1 ("LATIN-1") encoded files, which are very common with government data and such.
def fix_encoding(fn)
q = File.read(fn)
File.open(fn, 'w') { |f| f << q.encode("UTF-8", "ISO-8859-1") }
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment