lib/unicode/name.rb in unicode-name-1.1.0 vs lib/unicode/name.rb in unicode-name-1.2.0

- old
+ new

@@ -4,20 +4,28 @@ module Name # Don't overwrite Module.name def self.unicode_name(char) codepoint = char.unpack("U")[0] require_relative "name/index" unless defined? ::Unicode::Name::INDEX - INDEX[:NAMES][codepoint] + if res = INDEX[:NAMES][codepoint] + res + elsif INDEX[:CJK].any?{ |cjk_range| codepoint >= cjk_range[0] && codepoint <= cjk_range[1] } + "CJK UNIFIED IDEOGRAPH-%.4X" % codepoint + elsif codepoint >= INDEX[:HANGUL][0][0] && codepoint <= INDEX[:HANGUL][0][1] + "HANGUL SYLLABLE-%.4X" % codepoint + else + nil + end end class << self; alias of unicode_name; end def self.correct(char) codepoint = char.unpack("U")[0] require_relative "name/index" unless defined? ::Unicode::Name::INDEX if correction = INDEX[:ALIASES][codepoint] && INDEX[:ALIASES][codepoint][:correction][-1] correction else - INDEX[:NAMES][codepoint] + unicode_name(char) end end def self.aliases(char) codepoint = char.unpack("U")[0]