Methods
- C
- G
- N
Constants
VERBOSE_MODE | = | false |
Class Public methods
new(xml_path)
Link
Instance Public methods
conversion(from_carrier, to_carrier, &block)
Link
# File tool/enc-emoji4unicode.rb, line 17 def conversion(from_carrier, to_carrier, &block) REXML::XPath.each(@doc.root, '//e') do |e| from = e.attribute(from_carrier.downcase).to_s to = e.attribute(to_carrier.downcase).to_s text_fallback = e.attribute('text_fallback').to_s name = e.attribute('name').to_s if from =~ /^(?:\*|\+)(.+)$/ # proposed or unified from = $1 end if from.empty? || from !~ /^[0-9A-F]+$/ # do nothing else from_utf8 = [from.hex].pack("U").unpack("H*").first if to =~ /^(?:>|\*)?([0-9A-F\+]+)$/ str_to = $1 if str_to =~ /^\+/ # unicode "proposed" begins at "+" proposal = true str_to.sub!(/^\+/, '') else proposal = false end tos = str_to.split('+') to_utf8 = tos.map(&:hex).pack("U*").unpack("H*").first comment = "[%s] U+%X -> %s" % [name, from.hex, tos.map{|c| "U+%X"%c.hex}.join(' ')] block.call(:from => from_utf8, :to => to_utf8, :comment => comment, :fallback => false, :proposal => proposal) elsif to.empty? if text_fallback.empty? comment = "[%s] U+%X -> U+3013 (GETA)" % [name, from.hex] block.call(:from => from_utf8, :to => "\u{3013}".unpack("H*").first, :comment => comment, # geta :fallback => true, :proposal => false) else to_utf8 = text_fallback.unpack("H*").first comment = %Q([%s] U+%X -> "%s") % [name, from.hex, text_fallback] block.call(:from => from_utf8, :to => to_utf8, :comment => comment, :fallback => true, :proposal => false) end else raise "something wrong: %s -> %s" % [from, to] end end end end
generate(io, from_carrier, to_carrier)
Link
# File tool/enc-emoji4unicode.rb, line 70 def generate(io, from_carrier, to_carrier) from_encoding = (from_carrier == "Unicode") ? "UTF-8" : "UTF8-"+from_carrier to_encoding = (to_carrier == "Unicode" ) ? "UTF-8" : "UTF8-"+to_carrier io.puts "EMOJI_EXCHANGE_TBL['#{from_encoding}']['#{to_encoding}'] = [" io.puts " # for documented codepoints" if from_carrier == "KDDI" self.conversion(from_carrier, to_carrier) do |params| from, to = params[:from], %Q{"#{params[:to]}"} to = ":undef" if params[:fallback] || params[:proposal] io.puts %Q{ ["#{from}", #{to}], # #{params[:comment]}} end if from_carrier == "KDDI" io.puts " # for undocumented codepoints" self.conversion(from_carrier, to_carrier) do |params| from, to = params[:from], %Q{"#{params[:to]}"} to = ":undef" if params[:fallback] || params[:proposal] unicode = utf8_to_ucs(from) undoc = ucs_to_utf8(@kddi_undoc[unicode]) io.puts %Q{ ["#{undoc}", #{to}], # #{params[:comment]}} end end io.puts "]" io.puts end