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,
27 for (c
= 0; c
< 0x10000; c
++) {
36 for (i
= 0; i
< lenof(cs_table
); i
++)
37 if (cs_table
[i
]->read
== read_sbcs
&&
38 sbcs_from_unicode(cs_table
[i
]->data
, c
) != ERROR
) {
40 charset_to_localenc(cs_table
[i
]->charset
));
45 * Look up individually in MBCS base charsets.
47 if (unicode_to_big5(c
, &row
, &col
)) {
48 printf("%s Big5", sep
);
51 if (unicode_to_gb2312(c
, &row
, &col
)) {
52 printf("%s GB2312", sep
);
56 if (unicode_to_jisx0208(c
, &row
, &col
)) {
57 printf("%s JIS X 0208", sep
);
61 if (unicode_to_ksx1001(c
, &row
, &col
)) {
62 printf("%s KS X 1001", sep
);
66 if (unicode_to_cp949(c
, &row
, &col
)) {
67 printf("%s CP949", sep
);
72 printf(" unicode-only");