diff --git a/enc/unicode/case-folding.rb b/enc/unicode/case-folding.rb index 2191210617..f77c93b354 100755 --- a/enc/unicode/case-folding.rb +++ b/enc/unicode/case-folding.rb @@ -45,7 +45,7 @@ class CaseFolding include Util - attr_reader :fold, :fold_locale, :unfold, :unfold_locale + attr_reader :fold, :fold_locale, :unfold, :unfold_locale, :version def load(filename) pattern = /([0-9A-F]{4,6}); ([CFT]); ([0-9A-F]{4,6})(?: ([0-9A-F]{4,6}))?(?: ([0-9A-F]{4,6}))?;/ @@ -53,9 +53,11 @@ class CaseFolding @fold = fold = {} @unfold = unfold = [{}, {}, {}] @debug = false + @version = nil turkic = [] IO.foreach(filename, mode: "rb") do |line| + @version ||= line[/-([0-9.]+).txt/, 1] next unless res = pattern.match(line) ch_from = res[1].to_i(16) @@ -202,11 +204,14 @@ class MapItem end class CaseMapping - def initialize (mapping_directory) + attr_reader :filename, :version + + def initialize(mapping_directory) @mappings = {} @specials = [] @specials_length = 0 - IO.readlines(File.expand_path('UnicodeData.txt', mapping_directory), encoding: Encoding::ASCII_8BIT).each do |line| + @version = nil + IO.foreach(File.join(mapping_directory, 'UnicodeData.txt'), mode: "rb") do |line| next if line =~ /^