Skip to content

Instantly share code, notes, and snippets.

@matthieuprat
Last active June 28, 2017 13:41
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