Last active
September 3, 2021 23:35
-
-
Save pquimo/1059354 to your computer and use it in GitHub Desktop.
ruby code to detect non-ascii characters in files
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
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 |
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
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