]> git.saurik.com Git - wxWidgets.git/blob - misc/unictabl/mk_ctable.c
reverted the move of wxComboBox styles from wx/defs.h to wx/combobox.h, a lot of...
[wxWidgets.git] / misc / unictabl / mk_ctable.c
1
2 /* CVS-ID: $Id$ */
3
4 #include <stdio.h>
5
6 typedef struct {
7 unsigned char c;
8 unsigned short u;
9 } charsetItem;
10
11
12
13 int cmpt(const void *i1, const void *i2)
14 {
15 unsigned short u1 = ((charsetItem*)i1) -> u;
16 unsigned short u2 = ((charsetItem*)i2) -> u;
17 return (u1 - u2);
18 }
19
20
21
22 int main(int argc, char *argv[])
23 {
24 unsigned enc, unic;
25 unsigned i;
26 charsetItem table[256];
27
28 for (i = 0; i < 256; i++) { table[i].c = i, table[i].u = 0; /* unknown */}
29
30 while (!feof(stdin))
31 {
32 scanf("%i\t%i\n", &enc, &unic);
33 table[enc].u = unic;
34 table[enc].c = enc;
35 if (enc < 128 && enc != unic)
36 fprintf(stderr, "7bit ASCII incompatibilit (%s): %i->%i\n",
37 argv[2], enc, unic);
38 }
39
40 /* dump it: */
41
42 printf("\n\n"
43 "/*\n"
44 " * %s to Unicode recoding table\n"
45 " * based on file %s by Unicode Consortium\n"
46 " */\n\n"
47 "static const wxUint16 encoding_table__%s[128] = {",
48 argv[2], argv[1], argv[2]);
49
50 for (i = 128; i < 256; i++)
51 {
52 if (i % 8 == 0)
53 printf("\n ");
54 printf(" 0x%04X%c", table[i].u, (i == 255) ? '\n' : ',');
55 }
56 printf(" };\n");
57
58 qsort(table + 128, 128, sizeof(table[0]), cmpt);
59
60
61 /*
62 NO, WE DON'T NEED REVERSE TABLE, WE CAN BUILD IT AT RUNTIME
63 (won't take that much time, after all you don't init
64 conversion so often...)
65
66 printf("\n"
67 "static wxUint16 encoding_table_rev__%s[128] = {",
68 argv[2]);
69
70 for (i = 128; i < 256; i++)
71 {
72 if (i % 4 == 0)
73 printf("\n ");
74 printf("{c:0x%02X,u:0x%04X}%c ", table[i].c, table[i].u, (i == 255) ? '\n' : ',');
75 }
76 printf("};\n");
77 */
78
79 return 1;
80 }