1
/* Copyright (C) 2004 MySQL AB
3
This program is free software; you can redistribute it and/or modify
4
it under the terms of the GNU General Public License as published by
5
the Free Software Foundation; version 2 of the License.
7
This program is distributed in the hope that it will be useful,
8
but WITHOUT ANY WARRANTY; without even the implied warranty of
9
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10
GNU General Public License for more details.
12
You should have received a copy of the GNU General Public License
13
along with this program; if not, write to the Free Software
14
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
22
Dump an EastAsianWidth.txt file.
23
See http://www.unicode.org/reports/tr11/ for details.
34
int main(int ac, char **av)
42
memset(plane, 0, sizeof(plane));
43
memset(page, 0, sizeof(page));
45
while (fgets(str, sizeof(str), stdin))
47
int code1, code2, width;
52
code1= strtol(str, &end, 16);
53
if (code1 < 0 || code1 > 0xFFFF)
55
if (end[0] == ';') /* One character */
59
else if (end[0] == '.' && end[1] == '.') /* Range */
62
code2= strtol(end, &end, 16);
63
if (code2 < 0 || code2 > 0xFFFF)
68
fprintf(stderr, "error: %s", str);
75
fprintf(stderr, "error: %s", str);
80
width= (end[0] == 'F' || end[0] == 'W') ? 1 : 0;
82
for ( ; code1 <= code2; code1++)
91
for (i=0; i < 256; i++)
94
int *p= plane + 256 * i;
96
for (j=0; j < 256; j++)
100
if (page[i] != 0 && page[i] != 256)
102
printf("static char pg%02X[256]=\n{\n", i);
103
for (j=0; j < 256; j++)
105
printf("%d%s%s", p[j], j < 255 ? "," : "", (j + 1) % 32 ? "" : "\n");
111
printf("static struct {int page; char *p;} utr11_data[256]=\n{\n");
112
for (i=0; i < 256; i++)
114
if (page[i] == 0 || page[i] == 256)
116
int width= (page[i] == 256) ? 1 : 0;
117
printf("{%d,NULL}", width);
121
printf("{0,pg%02X}", i);
123
printf("%s%s", i < 255 ? "," : "", (i+1) % 8 ? "" : "\n");