* enc/unicode/case-folding.rb, enc/unicode/casefold.h: Flags for

upper/lower conversion added (titlecase and SpecialCasing still missing)
  (with Kimihito Matsui)


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53779 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
duerst 2016-02-08 12:26:35 +00:00
parent 2ca7569c6d
commit 73ab88994f
3 changed files with 2248 additions and 2236 deletions

View file

@ -1,3 +1,9 @@
Mon Feb 8 21:26:19 2016 Martin Duerst <duerst@it.aoyama.ac.jp>
* enc/unicode/case-folding.rb, enc/unicode/casefold.h: Flags for
upper/lower conversion added (titlecase and SpecialCasing still missing)
(with Kimihito Matsui)
Mon Feb 8 20:43:57 2016 Martin Duerst <duerst@it.aoyama.ac.jp> Mon Feb 8 20:43:57 2016 Martin Duerst <duerst@it.aoyama.ac.jp>
* string.c, enc/unicode.c: Disassociating ONIGENC_CASE_FOLD flag from * string.c, enc/unicode.c: Disassociating ONIGENC_CASE_FOLD flag from

View file

@ -20,7 +20,7 @@ class CaseFolding
def print_table_1(dest, type, mapping_data, data) def print_table_1(dest, type, mapping_data, data)
for k, v in data = data.sort for k, v in data = data.sort
sk = (Array === k and k.length > 1) ? "{#{hex_seq(k)}}" : ("0x%04x" % k) sk = (Array === k and k.length > 1) ? "{#{hex_seq(k)}}" : ("0x%04x" % k)
dest.print(" {#{sk}, {#{v.length}#{mapping_data.flags(k, type)}, {#{hex_seq(v)}}}},\n") dest.print(" {#{sk}, {#{v.length}#{mapping_data.flags(k, type, v)}, {#{hex_seq(v)}}}},\n")
end end
data data
end end
@ -178,6 +178,8 @@ class CaseFolding
end end
class MapItem class MapItem
attr_reader :upper, :lower
def initialize(code, upper, lower, title) def initialize(code, upper, lower, title)
@code = code @code = code
@upper = upper unless upper == '' @upper = upper unless upper == ''
@ -205,13 +207,17 @@ class CaseMapping
# IO.readlines(File.expand_path('SpecialCasing.txt', mapping_directory)) # IO.readlines(File.expand_path('SpecialCasing.txt', mapping_directory))
end end
def flags(from, type) def flags(from, type, to)
# types: CaseFold_11, CaseUnfold_11, CaseUnfold_12, CaseUnfold_13 # types: CaseFold_11, CaseUnfold_11, CaseUnfold_12, CaseUnfold_13
flags = "" flags = ""
flags += '|F' if type=='CaseFold_11' flags += '|F' if type=='CaseFold_11'
from = Array(from).map {|i| "%04X" % i}.join(" ")
#to = @mappings[from] to = Array(to).map {|i| "%04X" % i}.join(" ")
#to ? to.flags : "" item = @mappings[from]
if item
flags += '|U' if to==item.upper
flags += '|D' if to==item.lower
end
flags flags
end end
@ -221,7 +227,7 @@ class CaseMapping
end end
class CaseMappingDummy class CaseMappingDummy
def flags(from, type) def flags(from, type, to)
"" ""
end end
end end

File diff suppressed because it is too large Load diff