1 /* Copyright (C) 1999-2002, 2012, 2018 Free Software Foundation, Inc.
2 This file is part of the GNU LIBICONV Tools.
4 This program is free software: you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 3 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, see <https://www.gnu.org/licenses/>. */
18 * Generates Unicode variants table from Koichi Yasuoka's UniVariants file.
24 #define ENTRIES 8176 /* number of lines in UniVariants file */
25 #define MAX_PER_ENTRY 10 /* max number of entries per line in file */
27 int main (int argc
, char *argv
[])
29 int variants
[MAX_PER_ENTRY
*ENTRIES
];
30 int uni2index
[0x10000];
37 printf(" * Copyright (C) 1999-2002 Free Software Foundation, Inc.\n");
38 printf(" * This file is part of the GNU LIBICONV Library.\n");
40 printf(" * The GNU LIBICONV Library is free software; you can redistribute it\n");
41 printf(" * and/or modify it under the terms of the GNU Lesser General Public\n");
42 printf(" * License as published by the Free Software Foundation; either version 2\n");
43 printf(" * of the License, or (at your option) any later version.\n");
45 printf(" * The GNU LIBICONV Library is distributed in the hope that it will be\n");
46 printf(" * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of\n");
47 printf(" * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\n");
48 printf(" * Lesser General Public License for more details.\n");
50 printf(" * You should have received a copy of the GNU Lesser General Public\n");
51 printf(" * License along with the GNU LIBICONV Library; see the file COPYING.LIB.\n");
52 printf(" * If not, see <https://www.gnu.org/licenses/>.\n");
56 printf(" * CJK variants table\n");
62 for (j
= 0; j
< 0x10000; j
++)
70 do { c
= getc(stdin
); } while (!(c
== EOF
|| c
== '\n'));
74 if (scanf("%x",&j
) != 1)
82 if (scanf("%x",&i
) != 1)
84 if (!(i
>= 0x3000 && i
< 0x3000+0x8000))
86 variants
[index
++] = i
-0x3000;
91 variants
[index
-1] |= 0x8000; /* end of list marker */
96 printf("static const unsigned short cjk_variants[%d] = {",index
);
99 for (i
= 0; i
< index
; i
++) {
102 printf(" 0x%04x,",variants
[i
]);
107 printf("static const short cjk_variants_indx[0x5200] = {\n");
110 for (j
= 0x4e00; j
< 0xa000; j
++) {
111 if ((j
% 0x100) == 0)
112 printf(" /* 0x%04x */\n", j
);
115 printf(" %5d,",uni2index
[j
]);