Skip to content

Instantly share code, notes, and snippets.

@matthieuprat
Last active June 28, 2017 13:41
Show Gist options
  • Save matthieuprat/14a5ac4e116e567b16b51e6af3e58170 to your computer and use it in GitHub Desktop.
Save matthieuprat/14a5ac4e116e567b16b51e6af3e58170 to your computer and use it in GitHub Desktop.
Dealing with Excel encoding issues
string.chars.map.with_index do |c, i|
n = c.encode('windows-1252') rescue nil
n ||= c.encode('iso-8859-1') rescue nil
puts "#{i}: #{c}" unless n
n.bytes.first
end
.pack('C*')
.force_encoding('utf-8')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment