*** empty log message ***
[m17n/m17n-lib.git] / src / character.c
index c46cfa4..45ba1fd 100644 (file)
@@ -1,5 +1,5 @@
 /* character.c -- character module.
-   Copyright (C) 2003, 2004
+   Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010
      National Institute of Advanced Industrial Science and Technology (AIST)
      Registration Number H15PRO112
 
@@ -17,7 +17,7 @@
 
    You should have received a copy of the GNU Lesser General Public
    License along with the m17n library; if not, write to the Free
-   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
    02111-1307, USA.  */
 
 /***en
 
 /***ja
     @addtogroup m17nCharacter
-    @brief Ê¸»ú¥ª¥Ö¥¸¥§¥¯¥È¤È¤½¤ì¤Ë´Ø¤¹¤ë API
+    @brief Ê¸»ú¥ª¥Ö¥¸¥§¥¯¥È¤È¤½¤ì¤Ë´Ø¤¹¤ë API.
 
-    m17n ¥é¥¤¥Ö¥é¥ê¤Ï @e Ê¸»ú ¤òʸ»ú¥³¡¼¥É¡ÊÀ°¿ô¡Ë¤Çɽ¸½¤¹¤ë¡£ºÇ¾®¤Îʸ
-    »ú¥³¡¼¥É¤Ï @c 0 ¤Ç¡¢ºÇÂç¤Îʸ»ú¥³¡¼¥É¤Ï¥Þ¥¯¥í #MCHAR_MAX ¤Ë¤è¤Ã¤Æ
-    ÄêµÁ¤µ¤ì¤Æ¤¤¤ë¡£#MCHAR_MAX ¤Ï @c 0x3FFFFF¡Ê22¥Ó¥Ã¥È¡Ë°Ê¾å¤Ç¤¢¤ë
-    ¤³¤È¤¬Êݾڤµ¤ì¤Æ¤¤¤ë¡£
+    m17n ¥é¥¤¥Ö¥é¥ê¤Ï @e Ê¸»ú ¤òʸ»ú¥³¡¼¥É¡ÊÀ°¿ô¡Ë¤Çɽ¸½¤¹¤ë¡£
+    ºÇ¾®¤Îʸ»ú¥³¡¼¥É¤Ï @c 0 ¤Ç¤¢¤ê¡¢ºÇÂç¤Îʸ»ú¥³¡¼¥É¤Ï¥Þ¥¯¥í #MCHAR_MAX 
+    ¤Ë¤è¤Ã¤ÆÄêµÁ¤µ¤ì¤Æ¤¤¤ë¡£#MCHAR_MAX ¤Ï @c 0x3FFFFF¡Ê22¥Ó¥Ã¥È¡Ë
+    °Ê¾å¤Ç¤¢¤ë¤³¤È¤¬Êݾڤµ¤ì¤Æ¤¤¤ë¡£
 
-    @c 0 ¤«¤é @c 0x10FFFF ¤Þ¤Ç¤Îʸ»ú¤Ï¡¢¤½¤ì¤ÈƱ¤¸Ãͤò»ý¤Ä Unicode ¤Î
-    Ê¸»ú¤Ë³ä¤êÅö¤Æ¤é¤ì¤Æ¤¤¤ë¡£
+    @c 0 ¤«¤é @c 0x10FFFF ¤Þ¤Ç¤Îʸ»ú¤Ï¡¢¤½¤ì¤ÈƱ¤¸Ãͤò»ý¤Ä Unicode 
+    ¤Îʸ»ú¤Ë³ä¤êÅö¤Æ¤é¤ì¤Æ¤¤¤ë¡£
 
-    ³Æʸ»ú¤Ï @e Ê¸»ú¥×¥í¥Ñ¥Æ¥£ ¤È¸Æ¤Ö¥×¥í¥Ñ¥Æ¥£¤ò0¸Ä°Ê¾å»ý¤Ä¤³¤È¤¬¤Ç¤­
-    ¤ë¡£Ê¸»ú¥×¥í¥Ñ¥Æ¥£¤Ï @e ¥­¡¼ ¤È @e ÃÍ ¤«¤é¤Ê¤ë¡£¥­¡¼¤Ï¥·¥ó¥Ü¥ë¤Ç¤¢
-    ¤ê¡¢ÃͤϠ<tt>(void *)</tt> ·¿¤Ë¥­¥ã¥¹¥È¤Ç¤­¤ë¤â¤Î¤Ê¤é²¿¤Ç¤â¤è¤¤¡£ 
-    ¡Öʸ»ú C ¤Îʸ»ú¥×¥í¥Ñ¥Æ¥£¤Î¤¦¤Á¥­¡¼¤¬ @c K ¤Ç¤¢¤ë¤â¤Î¡×¤ò´Êñ¤Ë
-    ¡Öʸ»ú C ¤Î K ¥×¥í¥Ñ¥Æ¥£¡×¤È¸Æ¤Ö¤³¤È¤¬¤¢¤ë¡£  */
+    ³Æʸ»ú¤Ï @e Ê¸»ú¥×¥í¥Ñ¥Æ¥£ ¤È¸Æ¤Ö¥×¥í¥Ñ¥Æ¥£¤ò 0 ¸Ä°Ê¾å»ý¤Ä¤³¤È¤¬¤Ç¤­¤ë¡£
+    Ê¸»ú¥×¥í¥Ñ¥Æ¥£¤Ï @e ¥­¡¼ ¤È @e ÃÍ ¤«¤é¤Ê¤ë¡£
+    ¥­¡¼¤Ï¥·¥ó¥Ü¥ë¤Ç¤¢¤ê¡¢ÃͤϠ<tt>(void *)</tt> ·¿¤Ë¥­¥ã¥¹¥È¤Ç¤­¤ë¤â¤Î¤Ê¤é²¿¤Ç¤â¤è¤¤¡£ 
+    ¡Öʸ»ú C ¤Îʸ»ú¥×¥í¥Ñ¥Æ¥£¤Î¤¦¤Á¥­¡¼¤¬ K ¤Ç¤¢¤ë¤â¤Î¡×¤ò´Êñ¤Ë¡Öʸ»ú C 
+    ¤Î K ¥×¥í¥Ñ¥Æ¥£¡×¤È¸Æ¤Ö¤³¤È¤¬¤¢¤ë¡£  */
 /*=*/
 
 #if !defined (FOR_DOXYGEN) || defined (DOXYGEN_INTERNAL_MODULE)
@@ -95,22 +95,17 @@ free_string (int from, int to, void *str, void *arg)
 int
 mchar__init ()
 {
-  char_prop_list = mplist ();
-
-  Mname
-    = mchar_define_property ("name", Mstring);
-  Mcategory
-    = mchar_define_property ("category", Msymbol);
-  Mcombining_class
-    = mchar_define_property ("combining-class", Minteger);
-  Mbidi_category
-    = mchar_define_property ("bidirectional-category", Msymbol);
-  Msimple_case_folding
-    = mchar_define_property ("simple-case-folding", Minteger);
-  Mcomplicated_case_folding
-    = mchar_define_property ("complicated-case-folding", Mtext);
-  Mscript
-    = mchar_define_property ("script", Msymbol);
+  Mname = msymbol ("name");
+  Mcategory = msymbol ("category");
+  Mcombining_class = msymbol ("combining-class");
+  Mbidi_category = msymbol ("bidirectional-category");
+  Msimple_case_folding = msymbol ("simple-case-folding");
+  Mcomplicated_case_folding = msymbol ("complicated-case-folding");
+  Mcased = msymbol ("cased");
+  Msoft_dotted = msymbol ("soft-dotted");
+  Mcase_mapping = msymbol ("case-mapping");
+  Mblock = msymbol ("block");
+  Mscript = msymbol ("script");
 
   return 0;
 }
@@ -120,28 +115,68 @@ mchar__fini (void)
 {
   MPlist *p;
 
-  for (p = char_prop_list; mplist_key (p) != Mnil; p = mplist_next (p))
+  if (char_prop_list)
     {
-      MCharPropRecord *record = mplist_value (p);
-
-      if (record->table)
+      for (p = char_prop_list; mplist_key (p) != Mnil; p = mplist_next (p))
        {
-         if (record->type == Mstring)
-           mchartable_map (record->table, NULL, free_string, NULL);
-         M17N_OBJECT_UNREF (record->table);
+         MCharPropRecord *record = mplist_value (p);
+
+         if (record->table)
+           {
+             if (record->type == Mstring)
+               mchartable_map (record->table, NULL, free_string, NULL);
+             M17N_OBJECT_UNREF (record->table);
+           }
+         free (record);
        }
-      free (record);
+      M17N_OBJECT_UNREF (char_prop_list);
+    }
+}
+
+void
+mchar__define_prop (MSymbol key, MSymbol type, void *mdb)
+{
+  MCharPropRecord *record;
+
+  if (char_prop_list)
+    record = mplist_get (char_prop_list, key);
+  else
+    char_prop_list = mplist (), record = NULL;
+  if (record)
+    {
+      if (record->table)
+       M17N_OBJECT_UNREF (record->table);
+    }
+  else
+    {
+      MSTRUCT_CALLOC (record, MERROR_CHAR);
+      mplist_put (char_prop_list, key, record);
+    }
+
+  record->type = type;
+  record->mdb = mdb;
+  if (mdb)
+    {
+      record->table = NULL;
+    }
+  else
+    {
+      void *default_value = NULL;
+
+      if (type == Minteger)
+       default_value = (void *) -1;
+      record->table = mchartable (type, default_value);
     }
-  M17N_OBJECT_UNREF (char_prop_list);
 }
 
+
 /*** @} */
 #endif /* !FOR_DOXYGEN || DOXYGEN_INTERNAL_MODULE */
 \f
 /* External API */
 
-/*** @addtogroup m17nCharacter */
-/*** @{ */
+/*** @addtogroup m17nCharacter
+     @{ */
 /*=*/
 
 #ifdef FOR_DOXYGEN
@@ -151,24 +186,25 @@ mchar__fini (void)
     The macro #MCHAR_MAX gives the maximum character code.  */
 
 /***ja
-    @brief Ê¸»ú¥³¡¼¥É¤ÎºÇÂçÃÍ
+    @brief Ê¸»ú¥³¡¼¥É¤ÎºÇÂçÃÍ.
 
-    ¥Þ¥¯¥í #MCHAR_MAX ¤Ïʸ»ú¥³¡¼¥É¤ÎºÇÂçÃͤòÍ¿¤¨¤ë¡£  */
+    ¥Þ¥¯¥í #MCHAR_MAX ¤Ïʸ»ú¥³¡¼¥É¤ÎºÇÂçÃͤòɽ¤¹¡£  */
 
 #define MCHAR_MAX
 /*=*/
 #endif /* FOR_DOXYGEN */
 
 /***en
-    @ingroup m17nCharacter
     @name Variables: Keys of character properties
 
     These symbols are used as keys of character properties.  */
 
 /***ja
-     @name ÊÑ¿ô: Ê¸»ú¥×¥í¥Ñ¥Æ¥£¤Î¥­¡¼
+    @ingroup m17nCharacter
+    @name ÊÑ¿ô: Ê¸»ú¥×¥í¥Ñ¥Æ¥£¤Î¥­¡¼
+
+    ¤³¤ì¤é¤Î¥·¥ó¥Ü¥ë¤Ïʸ»ú¥×¥í¥Ñ¥Æ¥£¤Î¥­¡¼¤È¤·¤Æ»È¤ï¤ì¤ë¡£*/
 
-     ¤³¤ì¤é¤Î¥·¥ó¥Ü¥ë¤Ïʸ»ú¥×¥í¥Ñ¥Æ¥£¤Î¥­¡¼¤È¤·¤Æ»È¤ï¤ì¤ë¡£*/
 /*=*/
 /*** @{ */
 
@@ -183,11 +219,11 @@ mchar__fini (void)
     the <em>Unicode Technical Report #24</em>.  */
 
 /***ja
-    @brief ¥¹¥¯¥ê¥×¥È¤òɽ¤ï¤¹¥­¡¼
+    @brief ¥¹¥¯¥ê¥×¥È¤òɽ¤ï¤¹¥­¡¼.
 
-    ¥·¥ó¥Ü¥ë #Mscript ¤Ï <tt>"script"</tt> ¤È¤¤¤¦Ì¾Á°¤ò»ý¤Á¡¢Ê¸»ú¥×
-    ¥í¥Ñ¥Æ¥£¤Î¥­¡¼¤È¤·¤Æ»È¤ï¤ì¤ë¡£¤³¤Î¥×¥í¥Ñ¥Æ¥£¤ÎÃͤϡ¢¤³¤Îʸ»ú¤Î°¤¹
-    ¤ë¥¹¥¯¥ê¥×¥È¤òɽ¤ï¤¹¥·¥ó¥Ü¥ë¤Ç¤¢¤ë¡£
+    ¥·¥ó¥Ü¥ë #Mscript ¤Ï <tt>"script"</tt> 
+    ¤È¤¤¤¦Ì¾Á°¤ò»ý¤Á¡¢Ê¸»ú¥×¥í¥Ñ¥Æ¥£¤Î¥­¡¼¤È¤·¤Æ»È¤ï¤ì¤ë¡£
+    ¤³¤Î¥×¥í¥Ñ¥Æ¥£¤ÎÃͤϡ¢¤³¤Îʸ»ú¤Î°¤¹¤ë¥¹¥¯¥ê¥×¥È¤òɽ¤ï¤¹¥·¥ó¥Ü¥ë¤Ç¤¢¤ë¡£
 
     ¥¹¥¯¥ê¥×¥È¤òɽ¤ï¤¹¥·¥ó¥Ü¥ë¤Î̾Á°¤Ï¡¢<em>Unicode Technical Report
     #24</em> ¤Ë¥ê¥¹¥È¤µ¤ì¤Æ¤¤¤ë¤â¤Î¤Î¤¤¤º¤ì¤«¤Ç¤¢¤ë¡£  */
@@ -204,11 +240,11 @@ MSymbol Mscript;
     C-string representing the name of the character.  */
 
 /***ja
-    @brief Ì¾Á°¤òɽ¤ï¤¹¥­¡¼
+    @brief Ì¾Á°¤òɽ¤ï¤¹¥­¡¼.
 
-    ¥·¥ó¥Ü¥ë #Mname ¤Ï <tt>"name"</tt> ¤È¤¤¤¦Ì¾Á°¤ò»ý¤Á¡¢Ê¸»ú¥×¥í¥Ñ
-    ¥Æ¥£¤Î¥­¡¼¤È¤·¤Æ»È¤ï¤ì¤ë¡£¤³¤Î¥×¥í¥Ñ¥Æ¥£¤ÎÃͤϠC-string ¤Ç¤¢¤ê¡¢¤½
-    ¤Îʸ»ú¤Î̾Á°¤òɽ¤ï¤¹¡£  */
+    ¥·¥ó¥Ü¥ë #Mname ¤Ï <tt>"name"</tt> 
+    ¤È¤¤¤¦Ì¾Á°¤ò»ý¤Á¡¢Ê¸»ú¥×¥í¥Ñ¥Æ¥£¤Î¥­¡¼¤È¤·¤Æ»È¤ï¤ì¤ë¡£
+    ¤³¤Î¥×¥í¥Ñ¥Æ¥£¤ÎÃͤϤ½¤Îʸ»ú¤Î̾Á°¤òɽ¤ï¤¹ C ¤Îʸ»úÎó¤Ç¤¢¤ë¡£  */
 
 MSymbol Mname;
 
@@ -227,14 +263,14 @@ MSymbol Mname;
     Unicode.  */
 
 /***ja
-    @brief °ìÈÌ¥«¥Æ¥´¥ê¤òɽ¤ï¤¹¥­¡¼
+    @brief °ìÈÌ¥«¥Æ¥´¥ê¤òɽ¤ï¤¹¥­¡¼.
 
-    ¥·¥ó¥Ü¥ë #Mcategory ¤Ï <tt>"category"</tt> ¤È¤¤¤¦Ì¾Á°¤ò»ý¤Á¡¢Ê¸
-    »ú¥×¥í¥Ñ¥Æ¥£¤Î¥­¡¼¤È¤·¤Æ»È¤ï¤ì¤ë¡£¤³¤Î¥×¥í¥Ñ¥Æ¥£¤ÎÃͤϡ¢Âбþ¤¹¤ë
-    <em>°ìÈÌ¥«¥Æ¥´¥ê</em> ¤òɽ¤ï¤¹¥·¥ó¥Ü¥ë¤Ç¤¢¤ë¡£
+    ¥·¥ó¥Ü¥ë #Mcategory ¤Ï <tt>"category"</tt> 
+    ¤È¤¤¤¦Ì¾Á°¤ò»ý¤Á¡¢Ê¸»ú¥×¥í¥Ñ¥Æ¥£¤Î¥­¡¼¤È¤·¤Æ»È¤ï¤ì¤ë¡£
+    ¤³¤Î¥×¥í¥Ñ¥Æ¥£¤ÎÃͤϡ¢Âбþ¤¹¤ë <em>°ìÈÌ¥«¥Æ¥´¥ê</em> ¤òɽ¤ï¤¹¥·¥ó¥Ü¥ë¤Ç¤¢¤ë¡£
 
-    °ìÈÌ¥«¥Æ¥´¥ê¤òɽ¤ï¤¹¥·¥ó¥Ü¥ë¤Î̾Á°¤Ï¡¢<em>General Category</em>¤Î
-    ¾Êά·Á¤È¤·¤Æ Unicode ¤ËÄêµÁ¤µ¤ì¤Æ¤¤¤ë¤â¤Î¤Ç¤¢¤ë¡£  */
+    °ìÈÌ¥«¥Æ¥´¥ê¤òɽ¤ï¤¹¥·¥ó¥Ü¥ë¤Î̾Á°¤Ï¡¢<em>General Category</em> 
+    ¤Î¾Êά·Á¤È¤·¤Æ Unicode ¤ËÄêµÁ¤µ¤ì¤Æ¤¤¤ë¤â¤Î¤Ç¤¢¤ë¡£  */
 
 MSymbol Mcategory;
 
@@ -252,14 +288,14 @@ MSymbol Mcategory;
     class is identical to the one defined in Unicode.  */
 
 /***ja
-    @brief É¸½à·ë¹ç¥¯¥é¥¹¤òɽ¤ï¤¹¥­¡¼
+    @brief É¸½à·ë¹ç¥¯¥é¥¹¤òɽ¤ï¤¹¥­¡¼.
 
-    ¥·¥ó¥Ü¥ë #Mcombining_class ¤Ï <tt>"combining-class"</tt> ¤È¤¤¤¦
-    Ì¾Á°¤ò»ý¤Á¡¢Ê¸»ú¥×¥í¥Ñ¥Æ¥£¤Î¥­¡¼¤È¤·¤Æ»È¤ï¤ì¤ë¡£¤³¤Î¥×¥í¥Ñ¥Æ¥£¤ÎÃÍ
-    ¤Ï¡¢Âбþ¤¹¤ë @e É¸½à·ë¹ç¥¯¥é¥¹ ¤òɽ¤ï¤¹ÈóÉéÀ°¿ô¤Ç¤¢¤ë¡£
+    ¥·¥ó¥Ü¥ë #Mcombining_class ¤Ï <tt>"combining-class"</tt> 
+    ¤È¤¤¤¦Ì¾Á°¤ò»ý¤Á¡¢Ê¸»ú¥×¥í¥Ñ¥Æ¥£¤Î¥­¡¼¤È¤·¤Æ»È¤ï¤ì¤ë¡£
+    ¤³¤Î¥×¥í¥Ñ¥Æ¥£¤ÎÃͤϡ¢Âбþ¤¹¤ë @e É¸½à·ë¹ç¥¯¥é¥¹ ¤òɽ¤ï¤¹À°¿ô¤Ç¤¢¤ë¡£
 
-    É¸½à·ë¹ç¥¯¥é¥¹¤òɽ¤ï¤¹ÈóÉéÀ°¿ô¤Î°ÕÌ£¤Ï¡¢Unicode ¤ËÄêµÁ¤µ¤ì¤Æ¤¤¤ë¤â¤Î
-    ¤ÈƱ¤¸¤Ç¤¢¤ë¡£  */
+    É¸½à·ë¹ç¥¯¥é¥¹¤òɽ¤ï¤¹À°¿ô¤Î°ÕÌ£¤Ï¡¢Unicode 
+    ¤ËÄêµÁ¤µ¤ì¤Æ¤¤¤ë¤â¤Î¤ÈƱ¤¸¤Ç¤¢¤ë¡£  */
 
 MSymbol Mcombining_class;
 /*=*/
@@ -277,11 +313,11 @@ MSymbol Mcombining_class;
     Unicode.  */
 
 /***ja
-    @brief ÁÐÊý¸þ¥«¥Æ¥´¥ê¤òɽ¤ï¤¹¥­¡¼
+    @brief ÁÐÊý¸þ¥«¥Æ¥´¥ê¤òɽ¤ï¤¹¥­¡¼.
 
-    ¥·¥ó¥Ü¥ë #Mbidi_category ¤Ï <tt>"bidi-category"</tt> ¤È¤¤¤¦Ì¾Á°
-    ¤ò»ý¤Á¡¢Ê¸»ú¥×¥í¥Ñ¥Æ¥£¤Î¥­¡¼¤È¤·¤Æ»È¤ï¤ì¤ë¡£¤³¤Î¥×¥í¥Ñ¥Æ¥£¤ÎÃͤϡ¢
-    Âбþ¤¹¤ë @e ÁÐÊý¸þ¥«¥Æ¥´¥ê ¤òɽ¤ï¤¹¥·¥ó¥Ü¥ë¤Ç¤¢¤ë¡£
+    ¥·¥ó¥Ü¥ë #Mbidi_category ¤Ï <tt>"bidi-category"</tt> 
+    ¤È¤¤¤¦Ì¾Á°¤ò»ý¤Á¡¢Ê¸»ú¥×¥í¥Ñ¥Æ¥£¤Î¥­¡¼¤È¤·¤Æ»È¤ï¤ì¤ë¡£
+    ¤³¤Î¥×¥í¥Ñ¥Æ¥£¤ÎÃͤϡ¢Âбþ¤¹¤ë @e ÁÐÊý¸þ¥«¥Æ¥´¥ê ¤òɽ¤ï¤¹¥·¥ó¥Ü¥ë¤Ç¤¢¤ë¡£
 
     ÁÐÊý¸þ¥«¥Æ¥´¥ê¤òɽ¤ï¤¹¥·¥ó¥Ü¥ë¤Î̾Á°¤Ï¡¢<em>Bidirectional
     Category</em> ¤Î·¿¤È¤·¤Æ Unicode ¤ËÄêµÁ¤µ¤ì¤Æ¤¤¤ë¤â¤Î¤Ç¤¢¤ë¡£  */
@@ -304,20 +340,22 @@ MSymbol Mbidi_category;
     another property whose key is #Mcomplicated_case_folding.  */
 
 /***ja
-    @brief Âбþ¤¹¤ë¾®Ê¸»ú°ìʸ»ú¤òɽ¤ï¤¹¥­¡¼
+    @brief Âбþ¤¹¤ë¾®Ê¸»ú°ìʸ»ú¤òɽ¤ï¤¹¥­¡¼.
 
     ¥·¥ó¥Ü¥ë #Msimple_case_folding ¤Ï <tt>"simple-case-folding"</tt> 
-    ¤È¤¤¤¦Ì¾Á°¤ò»ý¤Á¡¢Ê¸»ú¥×¥í¥Ñ¥Æ¥£¤Î¥­¡¼¤È¤·¤Æ»È¤ï¤ì¤ë¡£¤³¤Î¥×¥í¥Ñ¥Æ¥£
-    ¤ÎÃͤϡ¢Âбþ¤¹¤ë¾®Ê¸»ú°ìʸ»ú¤Ç¤¢¤ê¡¢Âçʸ»ú¡¿¾®Ê¸»ú¤Î¶èÊ̤ò̵»ë¤·¤¿
-    Ê¸»úÎóÈæ³Ó¤ÎºÝ¤Ë»È¤ï¤ì¤ë¡£
+    ¤È¤¤¤¦Ì¾Á°¤ò»ý¤Á¡¢Ê¸»ú¥×¥í¥Ñ¥Æ¥£¤Î¥­¡¼¤È¤·¤Æ»È¤ï¤ì¤ë¡£
+    ¤³¤Î¥×¥í¥Ñ¥Æ¥£¤ÎÃͤϡ¢Âбþ¤¹¤ë¾®Ê¸»ú°ìʸ»ú¤Ç¤¢¤ê¡¢Âçʸ»ú¡¿¾®Ê¸»ú¤Î¶èÊ̤ò̵»ë¤·¤¿Ê¸»úÎóÈæ³Ó¤ÎºÝ¤Ë»È¤ï¤ì¤ë¡£
 
-    ¤â¤·¤½¤Î¤è¤¦¤ÊÈæ³Ó¤Ë»ÈÍѤ·ÆÀ¤ëñ°ì¤Î¾®Ê¸»ú¤¬Â¸ºß¤·¤Ê¤¤¾ì¹ç¡¢¤³¤Î¥×
-    ¥í¥Ñ¥Æ¥£¤ÎÃͤϠ0xFFFF ¤Ë¤Ê¤ë¡£¤³¤Î¾ì¹ç¤½¤Îʸ»ú¤Ï¡¢
-    #Mcomplicated_case_folding ¤È¤¤¤¦¥­¡¼¤Îʸ»ú¥×¥í¥Ñ¥Æ¥£¤ò»ý¤Ä¡£  */
+    Ê£»¨¤ÊÈæ³ÓÊýË¡¤òɬÍפȤ¹¤ëʸ»ú¤Ç¤¢¤Ã¤¿¾ì¹ç
+    ¡ÊÊ̤ΰìʸ»ú¤ÈÂбþÉÕ¤±¤ë¤³¤È¤Ë¤è¤Ã¤ÆÈæ³Ó¤Ç¤­¤Ê¤¤¾ì¹ç¡Ë¡¢¤³¤Î¥×¥í¥Ñ¥Æ¥£¤ÎÃͤϠ
+    @c 0xFFFF ¤Ë¤Ê¤ë¡£¤³¤Î¾ì¹ç¤½¤Îʸ»ú¤Ï¡¢#Mcomplicated_case_folding
+    ¤È¤¤¤¦¥­¡¼¤Îʸ»ú¥×¥í¥Ñ¥Æ¥£¤ò»ý¤Ä¡£  */
 
 MSymbol Msimple_case_folding;
+/*=*/
+
 /***en
-    @brief Key for corresponding multiple lowercase characters
+    @brief Key for corresponding multiple lowercase characters.
 
     The symbol #Mcomplicated_case_folding has the name
     <tt>"complicated-case-folding"</tt> and is used as the key of a
@@ -326,17 +364,97 @@ MSymbol Msimple_case_folding;
     characters to be used for comparing M-texts ignoring case.  */
 
 /***ja
-    @brief Âбþ¤¹¤ë¾®Ê¸»ú¤ÎÎó¤òɽ¤ï¤¹¥­¡¼
+    @brief Âбþ¤¹¤ë¾®Ê¸»ú¤ÎÎó¤òɽ¤ï¤¹¥­¡¼.
 
     ¥·¥ó¥Ü¥ë #Mcomplicated_case_folding ¤Ï 
-    <tt>"complicated-case-folding"</tt> ¤È¤¤¤¦Ì¾Á°¤ò»ý¤Á¡¢Ê¸»ú¥×¥í¥Ñ¥Æ¥£
-    ¤Î¥­¡¼¤È¤·¤Æ»È¤ï¤ì¤ë¡£¤³¤Î¥×¥í¥Ñ¥Æ¥£¤ÎÃͤϡ¢Âбþ¤¹¤ë¾®Ê¸»úÎ󤫤é¤Ê
-    ¤ë M-text ¤Ç¤¢¤ê¡¢Âçʸ»ú¡¿¾®Ê¸»ú¤Î¶èÊ̤ò̵»ë¤·¤¿Ê¸»úÎóÈæ³Ó¤ÎºÝ¤Ë»È
+    <tt>"complicated-case-folding"</tt> 
+    ¤È¤¤¤¦Ì¾Á°¤ò»ý¤Á¡¢Ê¸»ú¥×¥í¥Ñ¥Æ¥£¤Î¥­¡¼¤È¤·¤Æ»È¤ï¤ì¤ë¡£
+    ¤³¤Î¥×¥í¥Ñ¥Æ¥£¤ÎÃͤϡ¢Âбþ¤¹¤ë¾®Ê¸»úÎ󤫤é¤Ê¤ë M-text ¤Ç¤¢¤ê¡¢Âçʸ»ú¡¿¾®Ê¸»ú¤Î¶èÊ̤ò̵»ë¤·¤¿Ê¸»úÎóÈæ³Ó¤ÎºÝ¤Ë»È
     ¤ï¤ì¤ë¡£
       */
 
 MSymbol Mcomplicated_case_folding;
 /*=*/
+
+/***en
+    @brief Key for values used in case operation.
+
+    The symbol #Mcased has the name <tt>"cased"</tt> and is used as
+    the key of charater property.  The value of such a property is an
+    integer value 1, 2, or 3 representing "cased", "case-ignorable",
+    and both of them respective.  See the Unicode Standard 5.0
+    (Section 3.13 Default Case Algorithm) for the detail.
+ */
+
+/***ja
+    @brief Case ½èÍý¤ËÍѤ¤¤é¤ì¤ëÃͤΥ­¡¼.
+
+    ¥·¥ó¥Ü¥ë #Mcased ¤Ï¡¢<tt>"cased"</tt> ¤È¤¤¤¦Ì¾Á°¤ò»ý¤Á¡¢Ê¸»ú¥×¥í¥Ñ
+    ¥Æ¥£¤Î¥­¡¼¤È¤·¤Æ»È¤ï¤ì¤ë¡£¤³¤Î¥×¥í¥Ñ¥Æ¥£¤ÎÃͤÏÀ°¿ôÃÍ 1, 2, 3 ¤Î¤¤¤º
+    ¤ì¤«¤Ç¤¢¤ê¡¢¤½¤ì¤¾¤ì "cased", "case-ignorable", ¤½¤ÎξÊý¤ò°ÕÌ£¤¹¤ë¡£
+    ¾ÜºÙ¤Ë¤Ä¤¤¤Æ¤Ï¡¢the Unicode Standard 5.0 (Section 3.13 Default
+    Case Algorithm) »²¾È¡£
+ */
+MSymbol Mcased;
+
+/*=*/
+/***en
+    @brief Key for values used in case operation.
+
+    The symbol #Msoft_dotted has the name <tt>"soft-dotted"</tt> and
+    is used as the key of charater property.  The value of such a
+    property is #Mt if a character has "Soft_Dotted" property, and
+    #Mnil otherwise.  See the Unicode Standard 5.0 (Section 3.13
+    Default Case Algorithm) for the detail.  */
+
+/***ja
+    @brief Case ½èÍý¤ËÍѤ¤¤é¤ì¤ëÃͤΥ­¡¼.
+
+    ¥·¥ó¥Ü¥ë #Msoft_dotted ¤Ï¡¢<tt>"soft-dotted"</tt> ¤È¤¤¤¦Ì¾Á°¤ò»ý¤Á¡¢
+    Ê¸»ú¥×¥í¥Ñ¥Æ¥£¤Î¥­¡¼¤È¤·¤Æ»È¤ï¤ì¤ë¡£¤³¤Î¥×¥í¥Ñ¥Æ¥£¤ÎÃͤϡ¢Ê¸»ú¤¬
+    "Soft_Dotted"¥×¥í¥Ñ¥Æ¥£¤ò»ý¤Ä¾ì¹ç¤Ë¤Ï #Mt, ¤½¤¦¤Ç¤Ê¤±¤ì¤Ð #Mnil ¤Ç
+    ¤¢¤ë¡£ ¾ÜºÙ¤Ë¤Ä¤¤¤Æ¤Ï¡¢the Unicode Standard 5.0 (Section 3.13
+    Default Case Algorithm) »²¾È¡£
+ */
+MSymbol Msoft_dotted;
+
+/*=*/
+/***en 
+    @brief Key for values used in case operation.
+
+    The symbol #Mcase_mapping has the name <tt>"case-mapping"</tt> and
+    is used as the key of charater property.  The value of such a
+    property is a plist of three M-Texts; lower, title, and upper of
+    the corresponding character.  See the Unicode Standard 5.0
+    (Section 5.18 Case Mappings) for the detail.  */
+
+/***ja
+    @brief Case ½èÍý¤ËÍѤ¤¤é¤ì¤ëÃͤΥ­¡¼.
+
+    ¥·¥ó¥Ü¥ë #Mcase_mapping ¤Ï¡¢<tt>"case-mapping"</tt> ¤È¤¤¤¦Ì¾Á°¤ò¤â
+    ¤Á¡¢Ê¸»ú¥×¥í¥Ñ¥Æ¥£¤Î¥­¡¼¤È¤·¤Æ»È¤ï¤ì¤ë¡£¤³¤Î¥×¥í¥Ñ¥Æ¥£¤ÎÃͤϡ¢£³¤Ä
+    ¤Î M-text¡¢¤¹¤Ê¤ï¤Á¤½¤Îʸ»ú¤Î lower, title, ¤È upper¤«¤é¤Ê¤ë plist
+    ¤Ç¤¢¤ë¡£ ¾ÜºÙ¤Ë¤Ä¤¤¤Æ¤Ï¡¢the Unicode Standard 5.0 (Section 3.13
+    Default Case Algorithm) »²¾È¡£
+*/
+MSymbol Mcase_mapping;
+
+/*=*/
+/***en 
+    @brief Key for script block name.
+
+    The symbol #Mblock the name <tt>"block"</tt> and is used as the
+    key of charater property.  The value of such a property is a
+    symbol representing a script block of the corresponding
+    character.  */
+/***ja
+    @brief ¥¹¥¯¥ê¥×¥È¥Ö¥í¥Ã¥¯Ì¾¤òɽ¤¹¥­¡¼.
+
+    ¥·¥ó¥Ü¥ë #Mblock ¤Ï¡¢<tt>"block"</tt> ¤È¤¤¤¦Ì¾Á°¤ò¤â¤Á¡¢Ê¸»ú¥×¥í¥Ñ
+    ¥Æ¥£¤Î¥­¡¼¤È¤·¤Æ»È¤ï¤ì¤ë¡£¤³¤Î¥×¥í¥Ñ¥Æ¥£¤ÎÃͤϡ¢¤½¤Îʸ»ú¤Î¥¹¥¯¥ê¥×
+    ¥È¥Ö¥í¥Ã¥¯Ì¾¤òɽ¤¹¥·¥ó¥Ü¥ë¤Ç¤¢¤ë¡£*/
+MSymbol Mblock;
+
 /*** @} */
 /*=*/
 
@@ -353,15 +471,15 @@ MSymbol Mcomplicated_case_folding;
     $SYM.  Otherwise it returns #Mnil.  */
 
 /***ja
-    @brief Ê¸»ú¥×¥í¥Ñ¥Æ¥£¤òÄêµÁ¤¹¤ë
+    @brief Ê¸»ú¥×¥í¥Ñ¥Æ¥£¤òÄêµÁ¤¹¤ë.
 
     ´Ø¿ô mchar_define_property () ¤Ï¡¢ \<#Mchar_table, $TYPE, $SYM \>
-    ¤È¤¤¤¦¥¿¥°¤ò»ý¤Ã¤¿¥Ç¡¼¥¿¥Ù¡¼¥¹¤ò m17n ¸À¸ì¾ðÊó¥Ù¡¼¥¹¤«¤éõ¤¹¡£  ¤³
-    ¤³¤Ç $SYM ¤Ï $NAME ¤È¤¤¤¦Ì¾Á°¤Î¥·¥ó¥Ü¥ë¤Ç¤¢¤ë¡£$TYPE ¤Ï#Mstring,
+    ¤È¤¤¤¦¥¿¥°¤ò»ý¤Ã¤¿¥Ç¡¼¥¿¥Ù¡¼¥¹¤ò m17n ¸À¸ì¾ðÊó¥Ù¡¼¥¹¤«¤éõ¤¹¡£  
+    ¤³¤³¤Ç $SYM ¤Ï $NAME ¤È¤¤¤¦Ì¾Á°¤Î¥·¥ó¥Ü¥ë¤Ç¤¢¤ë¡£$TYPE ¤Ï#Mstring,
     #Mtext, #Msymbol, #Minteger, #Mplist ¤Î¤¤¤º¤ì¤«¤Ç¤Ê¤±¤ì¤Ð¤Ê¤é¤Ê¤¤¡£
 
     @return
-    ½èÍý¤ËÀ®¸ù¤¹¤ì¤Ð $SYM ¤òÊÖ¤¹¡£
+    ½èÍý¤ËÀ®¸ù¤¹¤ì¤Ð mchar_define_property () ¤Ï$SYM ¤òÊÖ¤¹¡£
     ¼ºÇÔ¤·¤¿¾ì¹ç¤Ï #Mnil ¤òÊÖ¤¹¡£  */
 
 /***
@@ -372,39 +490,15 @@ MSymbol Mcomplicated_case_folding;
     mchar_get_prop (), mchar_put_prop ()  */
 
 MSymbol
-mchar_define_property (char *name, MSymbol type)
+mchar_define_property (const char *name, MSymbol type)
 {
   MSymbol key = msymbol (name);
-  MCharPropRecord *record;
-
-  record = mplist_get (char_prop_list, key);
-  if (record)
-    {
-      if (record->table)
-       M17N_OBJECT_UNREF (record->table);
-    }
-  else
-    {
-      MSTRUCT_CALLOC (record, MERROR_CHAR);
-      mplist_put (char_prop_list, key, record);
-    }
-
-  record->type = type;
-  if (mdatabase__finder
-      && (record->mdb = (*mdatabase__finder) (Mchar_table, type, key, Mnil)))
-    {
-      record->table = NULL;
-    }
-  else
-    {
-      void *default_value = NULL;
-
-      record->mdb = NULL;
-      if (type == Minteger)
-       default_value = (void *) -1;
-      record->table = mchartable (type, default_value);
-    }
+  void *mdb;
 
+  mdb = mdatabase_find (Mchar_table, type, key, Mnil);
+  if (! mdb)
+    return Mnil;
+  mchar__define_prop (key, type, mdb);
   return key;
 }
 
@@ -422,18 +516,17 @@ mchar_define_property (char *name, MSymbol type)
     NULL.  */
 
 /***ja
-    @brief Ê¸»ú¥×¥í¥Ñ¥Æ¥£¤ÎÃͤòÆÀ¤ë
+    @brief Ê¸»ú¥×¥í¥Ñ¥Æ¥£¤ÎÃͤòÆÀ¤ë.
 
-    ´Ø¿ô mchar_get_prop () ¤Ï¡¢Ê¸»ú $C ¤Îʸ»ú¥×¥í¥Ñ¥Æ¥£Ãæ¡¢¥­¡¼¤¬ $KEY 
-    ¤Ç¤¢¤ë¤â¤Î¤òõ¤¹¡£
+    ´Ø¿ô mchar_get_prop () ¤Ï¡¢Ê¸»ú $C ¤Îʸ»ú¥×¥í¥Ñ¥Æ¥£¤Î¤¦¤Á¥­¡¼¤¬ 
+    $KEY ¤Ç¤¢¤ë¤â¤Î¤òõ¤¹¡£
 
     @return
-    ½èÍý¤¬À®¸ù¤¹¤ì¤Ð mchar_get_prop () ¤Ï¸«¤Ä¤«¤Ã¤¿¥×¥í¥Ñ¥Æ¥£¤ÎÃͤòÊÖ
-    ¤¹¡£¼ºÇÔ¤·¤¿¾ì¹ç¤Ï #Mnil ¤òÊÖ¤¹¡£
+    ½èÍý¤¬À®¸ù¤¹¤ì¤Ð mchar_get_prop () ¤Ï¸«¤Ä¤«¤Ã¤¿¥×¥í¥Ñ¥Æ¥£¤ÎÃͤòÊÖ¤¹¡£
+    ¼ºÇÔ¤·¤¿¾ì¹ç¤Ï @c NULL ¤òÊÖ¤¹¡£
 
     @latexonly \IPAlabel{mchar_get_prop} @endlatexonly
 */
-
 /***
     @errors
     @c MERROR_SYMBOL, @c MERROR_DB
@@ -446,12 +539,14 @@ mchar_get_prop (int c, MSymbol key)
 {
   MCharPropRecord *record;
 
+  if (! char_prop_list)
+    return NULL;
   record = mplist_get (char_prop_list, key);
   if (! record)
     return NULL;
   if (record->mdb)
     {
-      record->table = (*mdatabase__loader) (record->mdb);
+      record->table = mdatabase_load (record->mdb);
       if (! record->table)
        MERROR (MERROR_DB, NULL);
       record->mdb = NULL;
@@ -471,17 +566,14 @@ mchar_get_prop (int c, MSymbol key)
     @return
     If the operation was successful, mchar_put_prop () returns 0.
     Otherwise, it returns -1.  */
-
 /***ja
-    @brief Ê¸»ú¥×¥í¥Ñ¥Æ¥£¤ÎÃͤòÀßÄꤹ¤ë
+    @brief Ê¸»ú¥×¥í¥Ñ¥Æ¥£¤ÎÃͤòÀßÄꤹ¤ë.
 
-    ´Ø¿ô mchar_put_prop () ¤Ïʸ»ú $C ¤Îʸ»ú¥×¥í¥Ñ¥Æ¥£Ãæ¡¢¥­¡¼¤¬ $KEY ¤Ç
-    ¤¢¤ë¤â¤Î¤òõ¤·¡¢¤½¤ÎÃͤȤ·¤Æ $VAL ¤òÀßÄꤹ¤ë¡£
+    ´Ø¿ô mchar_put_prop () ¤Ï¡¢Ê¸»ú $C ¤Îʸ»ú¥×¥í¥Ñ¥Æ¥£¤Î¤¦¤Á¥­¡¼¤¬ $KEY 
+    ¤Ç¤¢¤ë¤â¤Î¤òõ¤·¡¢¤½¤ÎÃͤȤ·¤Æ $VAL ¤òÀßÄꤹ¤ë¡£
 
     @return
-    ½èÍý¤¬À®¸ù¤¹¤ì¤Ð mchar_put_prop () ¤Ï0¤òÊÖ¤¹¡£¼ºÇÔ¤·¤¿¾ì¹ç¤Ï-1¤òÊÖ
-    ¤¹¡£  */
-
+    ½èÍý¤¬À®¸ù¤¹¤ì¤Ð mchar_put_prop () ¤Ï0¤òÊÖ¤¹¡£¼ºÇÔ¤·¤¿¾ì¹ç¤Ï-1¤òÊÖ¤¹¡£  */
 /***
     @errors
     @c MERROR_SYMBOL, @c MERROR_DB
@@ -494,20 +586,70 @@ mchar_put_prop (int c, MSymbol key, void *val)
 {
   MCharPropRecord *record;
 
+  if (! char_prop_list)
+    MERROR (MERROR_CHAR, -1);
   record = mplist_get (char_prop_list, key);
   if (! record)
     return -1;
   if (record->mdb)
     {
-      record->table = (*mdatabase__loader) (record->mdb);
+      record->table = mdatabase_load (record->mdb);
       if (! record->table)
        MERROR (MERROR_DB, -1);
-      M17N_OBJECT_REF (record->table);
       record->mdb = NULL;
     }
   return mchartable_set (record->table, c, val);
 }
 
+/*=*/
+
+/***en
+    @brief Get the char-table for a character property.
+
+    The mchar_get_prop_table () function returns a char-table that
+    contains the character property whose key is $KEY.  If $TYPE is
+    not NULL, this function stores the type of the property in the
+    place pointed by $TYPE.  See mchar_define_property () for types of
+    character property.
+
+    @return
+    If $KEY is a valid character property key, this function returns a
+    char-table.  Otherwise NULL is retuned.  */
+
+/***ja
+    @brief Ê¸»ú¥×¥í¥Ñ¥Æ¥£¤Îʸ»ú¥Æ¡¼¥Ö¥ë¤òÆÀ¤ë.
+
+    ´Ø¿ô mchar_get_prop_table () ¤Ï¡¢¥­¡¼¤¬ $KEY ¤Ç¤¢¤ëʸ»ú¥×¥í¥Ñ¥Æ¥£
+    ¤ò´Þ¤àʸ»ú¥Æ¡¼¥Ö¥ë¤òÊÖ¤¹¡£¤â¤· $TYPE ¤¬ NULL ¤Ç¤Ê¤±¤ì¤Ð¡¢ $TYPE ¤Ç
+    »Ø¤µ¤ì¤ë¾ì½ê¤Ë¤½¤Îʸ»ú¤Î¥×¥í¥Ñ¥Æ¥£¤ò³ÊǼ¤¹¤ë¡£Ê¸»ú¥×¥í¥Ñ¥Æ¥£¤Î¼ïÎà
+    ¤Ë´Ø¤·¤Æ¤Ï mchar_define_property () ¤ò¸«¤è¡£
+
+    @return
+    ¤â¤· $KEY ¤¬ÀµÅö¤Êʸ»ú¥×¥í¥Ñ¥Æ¥£¤Î¥­¡¼¤Ç¤¢¤ì¤Ð¡¢Ê¸»ú¥Æ¡¼¥Ö¥ë¤¬ÊÖ¤µ
+    ¤ì¤ë¡£¤½¤¦¤Ç¤Ê¤¤¾ì¹ç¤Ï NULL ¤¬ÊÖ¤µ¤ì¤ë¡£  */
+
+MCharTable *
+mchar_get_prop_table (MSymbol key, MSymbol *type)
+{
+  MCharPropRecord *record;
+
+  if (! char_prop_list)
+    return NULL;
+  record = mplist_get (char_prop_list, key);
+  if (! record)
+    return NULL;
+  if (record->mdb)
+    {
+      record->table = mdatabase_load (record->mdb);
+      if (! record->table)
+       MERROR (MERROR_DB, NULL);
+      record->mdb = NULL;
+    }
+  if (type)
+    *type = record->type;
+  return record->table;
+}
+
 /*** @} */
 
 /*