Created
July 28, 2012 23:17
-
-
Save camertron/3195176 to your computer and use it in GitHub Desktop.
Dumping the decomposition map to yml
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
require 'twitter_cldr' | |
require 'fileutils' | |
require 'yaml' | |
OUTPUT_FILE = "/tmp/cldr/decomposition_map.yml" | |
CODE_POINT_MAX = 1114111 | |
decomps = {} | |
CODE_POINT_MAX.times do |i| | |
code_point = TwitterCldr::Shared::CodePoint.for_hex(i.to_s(16)) | |
if code_point | |
unless code_point.decomposition =~ /^</ || code_point.decomposition.strip.size == 0 | |
decomps[code_point.decomposition] = code_point.code_point | |
end | |
end | |
complete = ((i.to_f / CODE_POINT_MAX.to_f) * 100).round | |
$stdout.write("\r#{complete}% complete, found #{decomps.size} decompositions") | |
end | |
puts "" | |
FileUtils.mkdir_p(File.dirname(OUTPUT_FILE)) | |
File.open(OUTPUT_FILE, "w+") do |f| | |
f.write(YAML::dump(decomps)) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment