1
/* Copyright (C) 2003-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 */
19
static void print_short_array(unsigned short *a, size_t width)
23
for (i=0; i<=0xFF; i++)
25
const char *fmt= (width==4) ? "0x%04X" : "0x%02X";
26
printf(fmt,(int)a[i]);
27
printf("%s%s",i<0xFF?",":"",(i+1) % 8 ? "" :"\n");
38
unsigned short touni[256];
39
unsigned short fromuni[65536];
40
unsigned short fromstat[256];
43
bzero((void*)touni,sizeof(touni));
44
bzero((void*)fromuni,sizeof(fromuni));
45
bzero((void*)fromstat,sizeof(fromstat));
47
while (fgets(str,sizeof(str),stdin))
51
if ((str[0]=='#') || (2!=sscanf(str,"%x%x",&c,&u)))
53
if (c>0xFF || u>0xFFFF)
60
printf("unsigned short cs_to_uni[256]=");
61
print_short_array(touni, 4);
65
fromstat[touni[i]>>8]++;
72
printf("unsigned char pl%02X[256]=",i);
73
print_short_array(fromuni+i*256, 2);
77
printf("unsigned short *uni_to_cs[256]={\n");
84
printf("%s%s",i<255?",":"",((i+1) % 8) ? "":"\n");