summaryrefslogtreecommitdiff
path: root/enc/unicode/case-folding.rb
diff options
context:
space:
mode:
authorduerst <duerst@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-02-23 12:53:10 +0000
committerduerst <duerst@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-02-23 12:53:10 +0000
commit1cc579cb0036c4178f4279b9d505d0f6ba5d375a (patch)
tree809e0d8ed1ab89f66e196625526924bf9f05eee0 /enc/unicode/case-folding.rb
parent3c0bb8d6f4ece61843f4a26b115e6555d2bbc913 (diff)
* enc/unicode/case-folding.rb, casefold.h: Outputting actual titlecase
data (new table, with indices from other tables). * enc/unicode.c: Ignoring titlecase data indices for the moment. (with Kimihito Matsui) git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53906 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'enc/unicode/case-folding.rb')
-rwxr-xr-xenc/unicode/case-folding.rb23
1 files changed, 18 insertions, 5 deletions
diff --git a/enc/unicode/case-folding.rb b/enc/unicode/case-folding.rb
index 425c37a9f9..174808afaa 100755
--- a/enc/unicode/case-folding.rb
+++ b/enc/unicode/case-folding.rb
@@ -175,6 +175,9 @@ class CaseFolding
name = "CaseUnfold_13"
data = print_table(dest, name, mapping_data, name=>unfold[2])
dest.print lookup_hash(name, "CodePointList2", data)
+
+ # TitleCase
+ dest.print mapping_data.titlecase_output
end
def debug!
@@ -195,15 +198,12 @@ class MapItem
@lower = lower unless lower == ''
@title = title unless title == ''
end
-
- def flags
- "" # preliminary implementation
- end
end
class CaseMapping
def initialize (mapping_directory)
@mappings = {}
+ @titlecase = []
IO.readlines(File.expand_path('UnicodeData.txt', mapping_directory), encoding: Encoding::ASCII_8BIT).each do |line|
next if line =~ /^</
code, _1,_2,_3,_4,_5,_6,_7,_8,_9,_10,_11, upper, lower, title = line.chomp.split ';'
@@ -237,11 +237,22 @@ class CaseMapping
if item
flags += '|U' if to==item.upper
flags += '|D' if to==item.lower
- flags += '|T' unless item.upper==item.title
+ unless item.upper == item.title
+ flags += "|T(#{@titlecase.length})"
+ @titlecase << item
+ end
end
flags
end
+ def titlecase_output
+ "CodePointList3 TitleCase[] = {\n" +
+ @titlecase.map do |item|
+ chars = item.title.split(/ /)
+ " {#{chars.length}, {" + chars.map {|c| "0x"+c }.join(', ') + "}},\n"
+ end.join + "};\n"
+ end
+
def self.load(*args)
new(*args)
end
@@ -251,6 +262,8 @@ class CaseMappingDummy
def flags(from, type, to)
""
end
+
+ def titlecase_output() '' end
end
if $0 == __FILE__