1 /* Copyright (C) 1999, 2008 Free Software Foundation
3 This file is part of libgcj.
5 This software is copyrighted work licensed under the terms of the
6 Libgcj License. Please consult the file "LIBGCJ_LICENSE" for
12 #include "make-trie.h"
16 unsigned char b1
; /* 1st byte */
17 unsigned char b2
; /* 2nd byte */
18 unsigned short uc
; /* unicode value */
21 #define MAP(B1, B2, C) { B1, B2, C },
23 struct chval chtab_0201
[] = {
28 struct chval chtab_0208
[] = {
33 struct chval chtab_0212
[] = {
39 struct chval sorted
[] = {
40 #define MAP(B1, B2, C) { B1, B2, C },
43 #define MAP(B1, B2, C) { 0x80|B1, B2, C },
51 compare (void *p1
, void *p2
)
53 struct chval
*c1
= (struct chval
*) p1
;
54 struct chval
*c2
= (struct chval
*) p2
;
55 return (int) c1
->uc
- (int) c2
->uc
;
59 main(int argc
, char** argv
)
62 int min1
= 256, max1
= 0, min2
= 256, max2
= 0, count
= 0;
63 int low1_uc
= 0xFFFF, high1_uc
= 0;
64 int low2_uc
= 0xFFFF, high2_uc
= 0;
68 fprintf (stderr
, "missing argument!\n");
71 if (strcmp (argv
[1], "JIS0208") == 0)
73 else if (strcmp (argv
[1], "JIS0212") == 0)
75 else if (strcmp (argv
[1], "toJIS") == 0)
78 for (i
= 0; chtab_0201
[i
].b1
!= 255; i
++)
80 enter(chtab_0201
[i
].uc
, chtab_0201
[i
].b2
);
82 for (i
= 0; i
< 0x20; i
++)
87 for (i
= 0; chtab_0208
[i
].b1
!= 255; i
++)
89 enter(chtab_0208
[i
].uc
,
90 (chtab_0208
[i
].b1
<< 8) | chtab_0208
[i
].b2
);
92 for (i
= 0; chtab_0212
[i
].b1
!= 255; i
++)
94 enter(chtab_0212
[i
].uc
,
95 0x8000 | (chtab_0212
[i
].b1
<< 8) | chtab_0212
[i
].b2
);
97 print_table ("Unicode_to_JIS", stdout
);
102 fprintf (stderr
, "bad argument!");
105 for (i
= 0; chtab
[i
].b1
!= 255; i
++)
107 if (chtab
[i
].b1
< min1
) min1
= chtab
[i
].b1
;
108 if (chtab
[i
].b2
< min2
) min2
= chtab
[i
].b2
;
109 if (chtab
[i
].b1
> max1
) max1
= chtab
[i
].b1
;
110 if (chtab
[i
].b2
> max2
) max2
= chtab
[i
].b2
;
113 fprintf(stderr
, "1st byte ranges from %d to %d.\n", min1
, max1
);
114 fprintf(stderr
, "2nd byte ranges from %d to %d.\n", min2
, max2
);
116 fprintf(out
,"/* This file is automatically generated from %s.TXT. */\n",
118 fprintf(out
,"#pragma GCC java_exceptions\n");
119 fprintf(out
, "unsigned short %s_to_Unicode[%d][%d] = {\n",
120 argv
[1], max1
- min1
+ 1, max2
- min2
+ 1);
122 for (row
= min1
; row
<= max1
; row
++)
124 fprintf(out
, "/* 1st byte: %d */ { ", row
);
125 if (row
< chtab
[i
].b1
)
127 fprintf(out
, "0 }, /* unused row */\n");
129 else if (row
> chtab
[i
].b1
)
131 fprintf (stderr
, "error - char table out of order!\n");
137 for (col
= min2
; col
<= max2
; col
++)
139 if (row
== chtab
[i
].b1
&& col
== chtab
[i
].b2
)
141 int uc
= chtab
[i
].uc
;
156 fprintf (out
, " /* 2nd byte: %d */ 0x%04x",
160 else if (row
< chtab
[i
].b1
161 || (row
== chtab
[i
].b1
&& col
< chtab
[i
].b2
))
167 fprintf (stderr
, "error - char table out of order!\n");
171 fprintf (out
, ",\n");
173 fprintf(out
, row
== max1
? "}\n" : "},\n");
176 fprintf(out
, "};\n");
177 fprintf(stderr
, "total number of characters is %d.\n", count
);
178 fprintf(stderr
, "Range is 0x%04x-0x%04x and 0x%04x-0x%04x.\n",
179 low1_uc
, high1_uc
, low2_uc
, high2_uc
);