2 * cstable.c - libcharset supporting utility which draws up a map
3 * of the whole Unicode BMP and annotates it with details of which
4 * other character sets each character appears in.
6 * Note this is not a libcharset _client_; it is part of the
7 * libcharset _package_, using libcharset internals.
14 #define ENUM_CHARSET(x) extern charset_spec const charset_##x;
17 static charset_spec
const *const cs_table
[] = {
18 #define ENUM_CHARSET(x) &charset_##x,
23 int main(int argc
, char **argv
)
28 if (argc
> 1 && !strcmp(argv
[1], "-v"))
31 for (c
= 0; c
< 0x30000; c
++) {
32 int i
, plane
, row
, col
, chr
;
40 for (i
= 0; i
< lenof(cs_table
); i
++)
41 if (cs_table
[i
]->read
== read_sbcs
&&
42 (chr
= sbcs_from_unicode(cs_table
[i
]->data
, c
)) != ERROR
) {
44 charset_to_localenc(cs_table
[i
]->charset
));
51 * Look up individually in MBCS base charsets.
53 if (unicode_to_big5(c
, &row
, &col
)) {
54 printf("%s Big5", sep
);
56 printf("[%d,%d]", row
, col
);
59 if (unicode_to_gb2312(c
, &row
, &col
)) {
60 printf("%s GB2312", sep
);
62 printf("[%d,%d]", row
, col
);
66 if (unicode_to_jisx0208(c
, &row
, &col
)) {
67 printf("%s JIS X 0208", sep
);
69 printf("[%d,%d]", row
, col
);
73 if (unicode_to_ksx1001(c
, &row
, &col
)) {
74 printf("%s KS X 1001", sep
);
76 printf("[%d,%d]", row
, col
);
80 if (unicode_to_cp949(c
, &row
, &col
)) {
81 printf("%s CP949", sep
);
83 printf("[%d,%d]", row
, col
);
87 if (unicode_to_cns11643(c
, &plane
, &row
, &col
)) {
88 printf("%s CNS11643", sep
);
90 printf("[%d,%d,%d]", plane
, row
, col
);
95 printf(" unicode-only");