3 char db_dir[] = "/usr/local/lib/chise/char-db";
6 test_map_func (CHISE_Char_ID cid, CHISE_Feature_Table *db,
9 unsigned char buf[256];
11 printf ("(flags = %x)\n", valdatum->flags);
12 if (chise_value_size (valdatum) < 256)
14 strncpy (buf, chise_value_data (valdatum),
15 chise_value_size (valdatum));
16 buf[chise_value_size (valdatum)] = '\0';
17 printf ("#x%04X\t(%c)\t%s\n", cid, cid, buf);
20 printf ("#x%04X\t(%c)\t%s\n",
21 cid, cid, chise_value_to_c_string (valdatum));
26 main (int argc, char* argv[])
29 CHISE_CCS ccs_daikanwa;
30 CHISE_Feature ft_ideographic_structure;
31 CHISE_Feature ft_ascii;
32 int modemask = 0755; /* rwxr-xr-x */
33 DBTYPE real_subtype = DB_HASH;
35 CHISE_Char_ID char_id;
37 unsigned char buf[1024];
39 /* open a data-source */
40 ds = CHISE_DS_open (CHISE_DS_Berkeley_DB, db_dir,
41 real_subtype, modemask);
44 printf ("Can't open data source\n");
50 * get a character corresponding with Daikanwa number 364
54 char_id = chise_ds_decode_char (ds, "=daikanwa", 364);
56 /* setup a decoding-table */
58 = chise_ds_get_ccs (ds, "=daikanwa");
59 if (ccs_daikanwa == NULL)
61 printf ("Can't open CCS =daikanwa\n");
66 /* get a character from the decoding-table */
67 char_id = chise_ccs_decode (ccs_daikanwa, 364);
70 /* get a feature-value of the character */
71 ft_ideographic_structure
72 = chise_ds_get_feature (ds, "ideographic-structure");
73 if (chise_char_gets_feature_value
74 (char_id, ft_ideographic_structure, buf, sizeof (buf)) != NULL)
75 printf ("#x%X => %s\n", char_id, buf);
77 printf ("#x%X\n", char_id);
79 ft_ascii = chise_ds_get_feature (ds, "ascii");
80 chise_char_feature_value_iterate (ft_ascii, &test_map_func);
81 chise_char_feature_value_iterate (ft_ideographic_structure, &test_map_func);
83 /* close the data-source */