351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
|
# File 'ext/encoding/character/utf-8/data/generate-unicode-data.rb', line 351
def process(data)
path = File.join(data.dir, 'CaseFolding.txt')
File.process(path) do |line|
fields = line.chomp.sub(/\s*#.*/, '').split(/\s*;\s*/, -1)
fields.verify_size(4, path, FOLDING_CODE)
next if fields[FOLDING_STATUS] =~ /^[ST]$/
raw_code, code = fields[FOLDING_CODE], fields[FOLDING_CODE].to_i(16)
values = fields[FOLDING_MAPPING].split(/\s+/).map{ |s| s.to_i(16) }
if values.size == 1 &&
!(!data.value[code].nil? && data.value[code] >= 0x1000000) &&
!data.type[code].nil?
case data.type[code]
when 'Ll'
lower = code
when 'Lt'
lower = data.title_to_lower[code]
when 'Lu'
lower = data.value[code]
else
lower = code
end
next if lower == values[0]
end
string = values.pack('U*')
if string.length + 1 > data.casefold_longest
data.casefold_longest = string.length + 1
end
data.casefold.push([code, string.escape])
end
end
|