n.c.
[chise/ruby.git] / chise / character.rb
index 190792f..c133c53 100755 (executable)
@@ -4,6 +4,8 @@ require "singleton"
 require "chise/parser"
 require "chise/chisedb"
 require "chise/iconv"
+require "chise/utf8"
+require "chise/ids"
 
 module CHISE
   class CharacterFactory # generate Character object and cache them
@@ -33,13 +35,17 @@ module CHISE
   end
 
   class Character
+    include UTF8Value
+    include IDS_Module
+
     def initialize(char_id)
       raise if char_id.nil?
-      raise unless char_id.is_a?(Fixnum) # char_id sure is a Fixnum.
-      raise if char_id < 0 # char_id sure is a positive value.
+      raise unless char_id.kind_of?(Integer) # make sure char_id is Integer.
+      raise if char_id < 0 # make sure char_id is positive.
       @char_id = char_id
       @char_id.freeze
-      @utf8_mcs = CHISE.i_tou8(@char_id)
+      # @utf8_mcs = CHISE.i_tou8(@char_id)
+      @utf8_mcs = itou8(@char_id)
       @utf8_mcs.freeze
       @feature = {}
       @check_all_done = nil
@@ -106,6 +112,16 @@ module CHISE
       en.to_er(self)
     end
 
+    def is_idc?
+      0x2ff0 <= @char_id && @char_id <= 0x2fff
+    end
+
+    def idc_argument_number
+      return 0 unless is_idc?
+      return 3 if @char_id == 0x2ff2 || @char_id == 0x2ff3
+      return 2
+    end
+
     private
 
     def get_feature(f)