Skip to content

Instantly share code, notes, and snippets.

@pquimo
Last active September 3, 2021 23:35
Show Gist options
  • Save pquimo/1059354 to your computer and use it in GitHub Desktop.
Save pquimo/1059354 to your computer and use it in GitHub Desktop.
ruby code to detect non-ascii characters in files
index = 0
str.each_char do |char|
index += 1
unless char.ascii_only?
puts "char at #{index} == ***#{char.inspect}***"
puts str.slice(index - 10, 20)
end
end
Dir.glob('**/*.{java,js,html,txt}').each do |filename|
contents = File.read(filename)
puts filename unless contents.ascii_only?
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment