Last active
June 28, 2017 13:41
-
-
Save matthieuprat/14a5ac4e116e567b16b51e6af3e58170 to your computer and use it in GitHub Desktop.
Dealing with Excel encoding issues
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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