lib/unicode/name.rb in unicode-name-1.0.0 vs lib/unicode/name.rb in unicode-name-1.1.0
- old
+ new
@@ -24,16 +24,15 @@
codepoint = char.unpack("U")[0]
require_relative "name/index" unless defined? ::Unicode::Name::INDEX
INDEX[:ALIASES][codepoint]
end
-=begin
def self.label(char)
codepoint = char.unpack("U")[0]
- codepoint_pretty = codepoint.to_s(16).upcase
+ codepoint_pretty = "%.4X" % codepoint
require_relative "name/index" unless defined? ::Unicode::Name::INDEX
- require "unicode/types/index" unless defined? ::Unicode::Types::INDEX
+ require "unicode/types" unless defined? ::Unicode::Types
case Unicode::Types.type(char)
when "Graphic", "Format"
nil
when "Control"
"<control-#{codepoint_pretty}>"
@@ -45,19 +44,18 @@
"<noncharacter-#{codepoint_pretty}>"
when "Reserved"
"<reserved-#{codepoint_pretty}>"
end
end
-=end
def self.readable(char)
unicode_name(char) ||
( as = aliases(char) ) &&
( as[:control] && as[:control][0] ||
as[:figment] && as[:figment][0] ||
as[:alternate] && as[:alternate][0] ||
- as[:abbreviation] && as[:abbreviation][0] ) #||
- # label(char)
+ as[:abbreviation] && as[:abbreviation][0] ) ||
+ label(char)
end
end
end