Created
March 30, 2011 10:27
-
-
Save Tho85/894178 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
require "set" | |
def all_chars_in_file(file) | |
all_chars = Set.new | |
File.open(file).each_line do |line| | |
line.chars.inject(all_chars) { |s,c| s << c } | |
end | |
all_chars | |
end | |
def all_utf8_chars_in_file(file) | |
Hash[all_chars_in_file(file).select { |c| c.ord > 255 }.map{|c| ['u%04x' % c.ord, c]}] | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment