Version 4.2.0.1, tag libreoffice-4.2.0.1
[LibreOffice.git] / sal / textenc / generate / cns116431992.pl
blob1d913101b50a0508484aef6a8e4db29f583b1ca6
1 #!/usr/bin/perl
3 # This file is part of the LibreOffice project.
5 # This Source Code Form is subject to the terms of the Mozilla Public
6 # License, v. 2.0. If a copy of the MPL was not distributed with this
7 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 # This file incorporates work covered by the following license notice:
11 # Licensed to the Apache Software Foundation (ASF) under one or more
12 # contributor license agreements. See the NOTICE file distributed
13 # with this work for additional information regarding copyright
14 # ownership. The ASF licenses this file to you under the Apache
15 # License, Version 2.0 (the "License"); you may not use this file
16 # except in compliance with the License. You may obtain a copy of
17 # the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 # The following files must be available in a ./input subdir:
22 # <http://www.unicode.org/Public/UNIDATA/Unihan.txt>:
23 # "Unicode version: 3.1.1 Table version: 1.1 Date: 28 June 2001"
24 # contains descriptions for:
25 # U+3400..4DFF CJK Unified Ideographs Extension A
26 # U+4E00..9FFF CJK Unified Ideographs
27 # U+F900..FAFF CJK Compatibility Ideographs
28 # U+20000..2F7FF CJK Unified Ideographs Extension B
29 # U+2F800..2FFFF CJK Compatibility Ideographs Supplement
31 # <http://www.unicode.org/Public/MAPPINGS/OBSOLETE/EASTASIA/CNS11643.TXT>:
32 # "Unicode version: 1.1 Table version: 0.0d1 Date: 21 October 1994"
33 # contains mappings for CNS 11643-1986
35 # <http://kanji.zinbun.kyoto-u.ac.jp/~yasuoka/ftp/CJKtable/Uni2CNS.Z>:
36 # "Unicode version: 1.1 Table version: 0.49 Date: 26 March 1998"
37 # contains mappings for CNS 11643-1992 that are incompatible with
38 # CNS11643.TXT
40 $id = "Cns116431992";
42 sub isValidUtf32
44 my $utf32 = $_[0];
45 return $utf32 >= 0 && $utf32 <= 0x10FFFF
46 && !($utf32 >= 0xD800 && $utf32 <= 0xDFFF)
47 && !($utf32 >= 0xFDD0 && $utf32 <= 0xFDEF)
48 && ($utf32 & 0xFFFF) < 0xFFFE;
51 sub printUtf32
53 my $utf32 = $_[0];
54 return sprintf("U+%04X", $utf32);
57 sub isValidCns116431992
59 my $plane = $_[0];
60 my $row = $_[1];
61 my $column = $_[2];
62 return $plane >= 1 && $plane <= 16
63 && $row >= 1 && $row <= 94
64 && $column >= 1 && $column <= 94;
67 sub printCns116431992
69 my $plane = $_[0];
70 my $row = $_[1];
71 my $column = $_[2];
72 return sprintf("%d-%02d/%02d", $plane, $row, $column);
75 sub printStats
77 my $used = $_[0];
78 my $space = $_[1];
79 return sprintf("%d/%d bytes (%.1f%%)",
80 $used,
81 $space,
82 $used * 100 / $space);
85 sub printSpaces
87 my $column_width = $_[0];
88 my $columns_per_line = $_[1];
89 my $end = $_[2];
90 $output = "";
91 for ($i = int($end / $columns_per_line) * $columns_per_line;
92 $i < $end;
93 ++$i)
95 for ($j = 0; $j < $column_width; ++$j)
97 $output = $output . " ";
100 return $output;
103 $count_Unihan_txt = 0;
104 $count_CNS11643_TXT = 0;
105 $count_Uni2CNS = 0;
107 if (1)
109 $filename = "Unihan.txt";
110 open IN, ("input/" . $filename) or die "Cannot read " . $filename;
111 while (<IN>)
113 if (/^U\+([0-9A-F]+)\tkCNS1992\t([0-9A-F])-([0-9A-F][0-9A-F])([0-9A-F][0-9A-F])$/)
115 $utf32 = oct("0x" . $1);
116 $cns_plane = oct("0x" . $2);
117 $cns_row = oct("0x" . $3) - 0x20;
118 $cns_column = oct("0x" . $4) - 0x20;
119 isValidUtf32($utf32)
120 or die "Bad UTF32 char U+" . printUtf32($utf32);
121 isValidCns116431992($cns_plane, $cns_row, $cns_column)
122 or die "Bad CNS11643-1992 char "
123 . printCns116431992($cns_plane,
124 $cns_row,
125 $cns_column);
126 if (!defined($cns_map[$cns_plane][$cns_row][$cns_column]))
128 $cns_map[$cns_plane][$cns_row][$cns_column] = $utf32;
129 $cns_plane_used[$cns_plane] = 1;
130 ++$count_Unihan_txt;
132 else
134 ($cns_map[$cns_plane][$cns_row][$cns_column] == $utf32)
135 or die "Mapping "
136 . printCns116431992($cns_plane,
137 $cns_row,
138 $cns_column)
139 . " to "
140 . printUtf32($cns_map[$cns_plane]
141 [$cns_row]
142 [$cns_column])
143 . ", NOT "
144 . printUtf32($utf32);
147 elsif (/^U\+([0-9A-F]+)\tkIRG_TSource\t([0-9A-F])-([0-9A-F][0-9A-F])([0-9A-F][0-9A-F])$/)
149 $utf32 = oct("0x" . $1);
150 $cns_plane = oct("0x" . $2);
151 $cns_row = oct("0x" . $3) - 0x20;
152 $cns_column = oct("0x" . $4) - 0x20;
153 isValidUtf32($utf32)
154 or die "Bad UTF32 char U+" . printUtf32($utf32);
155 isValidCns116431992($cns_plane, $cns_row, $cns_column)
156 or die "Bad CNS11643-1992 char "
157 . printCns116431992($cns_plane,
158 $cns_row,
159 $cns_column);
160 if (!defined($cns_map[$cns_plane][$cns_row][$cns_column]))
162 $cns_map[$cns_plane][$cns_row][$cns_column] = $utf32;
163 $cns_plane_used[$cns_plane] = 1;
164 ++$count_Unihan_txt;
166 else
168 ($cns_map[$cns_plane][$cns_row][$cns_column] == $utf32)
169 or print "WARNING! Mapping ",
170 printCns116431992($cns_plane,
171 $cns_row,
172 $cns_column),
173 " to ",
174 printUtf32($cns_map[$cns_plane]
175 [$cns_row]
176 [$cns_column]),
177 ", NOT ",
178 printUtf32($utf32),
179 "\n";
182 elsif (/^U\+([0-9A-F]+)\tkCNS1992\t.*$/)
184 die "Bad format";
187 close IN;
190 if (1)
192 $filename = "CNS11643.TXT";
193 open IN, ("input/" . $filename) or die "Cannot read " . $filename;
194 while (<IN>)
196 if (/0x([0-9A-F])([0-9A-F][0-9A-F])([0-9A-F][0-9A-F])\t0x([0-9A-F]+)\t\#.*$/)
198 $utf32 = oct("0x" . $4);
199 $cns_plane = oct("0x" . $1);
200 $cns_row = oct("0x" . $2) - 0x20;
201 $cns_column = oct("0x" . $3) - 0x20;
202 isValidUtf32($utf32)
203 or die "Bad UTF32 char U+" . printUtf32($utf32);
204 isValidCns116431992($cns_plane, $cns_row, $cns_column)
205 or die "Bad CNS11643-1992 char "
206 . printCns116431992($cns_plane,
207 $cns_row,
208 $cns_column);
209 if ($cns_plane <= 2)
211 if (!defined($cns_map[$cns_plane][$cns_row][$cns_column]))
213 $cns_map[$cns_plane][$cns_row][$cns_column] = $utf32;
214 $cns_plane_used[$cns_plane] = 1;
215 ++$count_CNS11643_TXT;
217 else
219 ($cns_map[$cns_plane][$cns_row][$cns_column] == $utf32)
220 or die "Mapping "
221 . printCns116431992($cns_plane,
222 $cns_row,
223 $cns_column)
224 . " to "
225 . printUtf32($cns_map[$cns_plane]
226 [$cns_row]
227 [$cns_column])
228 . ", NOT "
229 . printUtf32($utf32);
234 close IN;
237 if (0)
239 $filename = "Uni2CNS";
240 open IN, ("input/" . $filename) or die "Cannot read " . $filename;
241 while (<IN>)
243 if (/([0-9A-F]+)\t([0-9A-F])-([0-9A-F][0-9A-F])([0-9A-F][0-9A-F])\t.*$/)
245 $utf32 = oct("0x" . $1);
246 $cns_plane = oct("0x" . $2);
247 $cns_row = oct("0x" . $3) - 0x20;
248 $cns_column = oct("0x" . $4) - 0x20;
249 isValidUtf32($utf32)
250 or die "Bad UTF32 char U+" . printUtf32($utf32);
251 isValidCns116431992($cns_plane, $cns_row, $cns_column)
252 or die "Bad CNS11643-1992 char "
253 . printCns116431992($cns_plane,
254 $cns_row,
255 $cns_column);
256 if (!defined($cns_map[$cns_plane][$cns_row][$cns_column]))
258 $cns_map[$cns_plane][$cns_row][$cns_column] = $utf32;
259 $cns_plane_used[$cns_plane] = 1;
260 ++$count_Uni2CNS;
262 else
264 # ($cns_map[$cns_plane][$cns_row][$cns_column] == $utf32)
265 # or die "Mapping "
266 # . printCns116431992($cns_plane,
267 # $cns_row,
268 # $cns_column)
269 # . " to "
270 # . printUtf32($cns_map[$cns_plane]
271 # [$cns_row]
272 # [$cns_column])
273 # . ", NOT "
274 # . printUtf32($utf32);
276 if ($cns_plane == 1)
278 print printCns116431992($cns_plane, $cns_row, $cns_column),
279 "\n";
283 close IN;
286 for ($cns_plane = 1; $cns_plane <= 16; ++$cns_plane)
288 if (defined($cns_plane_used[$cns_plane]))
290 for ($cns_row = 1; $cns_row <= 94; ++$cns_row)
292 for ($cns_column = 1; $cns_column <= 94; ++$cns_column)
294 if (defined($cns_map[$cns_plane][$cns_row][$cns_column]))
296 $utf32 = $cns_map[$cns_plane][$cns_row][$cns_column];
297 $uni_plane = $utf32 >> 16;
298 $uni_page = ($utf32 >> 8) & 0xFF;
299 $uni_index = $utf32 & 0xFF;
300 if (!defined($uni_plane_used[$uni_plane])
301 || !defined($uni_page_used[$uni_plane][$uni_page])
302 || !defined($uni_map[$uni_plane]
303 [$uni_page]
304 [$uni_index]))
306 $uni_map[$uni_plane][$uni_page][$uni_index]
307 = ($cns_plane << 16)
308 | ($cns_row << 8)
309 | $cns_column;
310 $uni_plane_used[$uni_plane] = 1;
311 $uni_page_used[$uni_plane][$uni_page] = 1;
313 else
315 $cns1 = $uni_map[$uni_plane][$uni_page][$uni_index];
316 $cns1_plane = $cns1 >> 16;
317 $cns1_row = ($cns1 >> 8) & 0xFF;
318 $cns1_column = $cns1 & 0xFF;
320 # Do not map from Unicode to Fictious Character Set
321 # Extensions (Lunde, p. 131), if possible:
322 if ($cns_plane == 3
323 && ($cns_row == 66 && $cns_column > 38
324 || $cns_row > 66))
326 print " (",
327 printUtf32($utf32),
328 " to fictious ",
329 printCns116431992($cns_plane,
330 $cns_row,
331 $cns_column),
332 " ignored, favouring ",
333 printCns116431992($cns1_plane,
334 $cns1_row,
335 $cns1_column),
336 ")\n";
338 elsif ($cns1_plane == 3
339 && ($cns1_row == 66 && $cns1_column > 38
340 || $cns1_row > 66))
342 $uni_map[$uni_plane][$uni_page][$uni_index]
343 = ($cns_plane << 16)
344 | ($cns_row << 8)
345 | $cns_column;
346 print " (",
347 printUtf32($utf32),
348 " to fictious ",
349 printCns116431992($cns1_plane,
350 $cns1_row,
351 $cns1_column),
352 " ignored, favouring ",
353 printCns116431992($cns_plane,
354 $cns_row,
355 $cns_column),
356 ")\n";
358 else
360 print "WARNING! Mapping ",
361 printUtf32($utf32),
362 " to ",
363 printCns116431992($cns1_plane,
364 $cns1_row,
365 $cns1_column),
366 ", NOT ",
367 printCns116431992($cns_plane,
368 $cns_row,
369 $cns_column),
370 "\n";
378 if (defined($uni_plane_used[0]) && defined($uni_page_used[0][0]))
380 for ($utf32 = 0; $utf32 <= 0x7F; ++$utf32)
382 if (defined($uni_map[0][0][$uni_index]))
384 $cns = $uni_map[0][0][$utf32];
385 die "Mapping "
386 . printUtf32($utf32)
387 . " to "
388 . printCns116431992($cns >> 16,
389 ($cns >> 8) & 0xFF,
390 $cns & 0xFF);
395 $filename = lc($id) . ".tab";
396 open OUT, ("> " . $filename) or die "Cannot write " . $filename;
399 $filename = lc($id). ".pl";
400 open IN, $filename or die "Cannot read ". $filename;
401 $first = 1;
402 while (<IN>)
404 if (/^\#!.*$/)
407 elsif (/^\#(\*.*)$/)
409 if ($first == 1)
411 print OUT "/", $1, "\n";
412 $first = 0;
414 else
416 print OUT " ", substr($1, 0, length($1) - 1), "/\n";
419 elsif (/^\# (.*)$/)
421 print OUT " *", $1, "\n";
423 elsif (/^\#(.*)$/)
425 print OUT " *", $1, "\n";
427 else
429 goto done;
432 done:
435 print OUT "\n",
436 "#ifndef _SAL_TYPES_H_\n",
437 "#include \"sal/types.h\"\n",
438 "#endif\n",
439 "\n";
441 print OUT "static sal_uInt16 const aImpl", $id, "ToUnicodeData[] = {\n";
442 $cns_data_index = 0;
443 for ($cns_plane = 1; $cns_plane <= 16; ++$cns_plane)
445 if (defined($cns_plane_used[$cns_plane]))
447 $cns_rows = 0;
448 $cns_chars = 0;
449 for ($cns_row = 1; $cns_row <= 94; ++$cns_row)
451 $cns_row_first = -1;
452 for ($cns_column = 1; $cns_column <= 94; ++$cns_column)
454 if (defined($cns_map[$cns_plane][$cns_row][$cns_column]))
456 if ($cns_row_first == -1)
458 $cns_row_first = $cns_column;
460 $cns_row_last = $cns_column;
463 if ($cns_row_first != -1)
465 $cns_data_offsets[$cns_plane][$cns_row] = $cns_data_index;
466 ++$cns_rows;
467 print OUT " /* plane ", $cns_plane, ", row ", $cns_row,
468 " */\n";
470 $cns_row_surrogates_first = -1;
471 $cns_row_chars = 0;
472 $cns_row_surrogates = 0;
474 print OUT " ", $cns_row_first, " | (", $cns_row_last,
475 " << 8), /* first, last */\n";
476 ++$cns_data_index;
478 print OUT " ", printSpaces(7, 10, $cns_row_first);
479 $bol = 0;
480 for ($cns_column = $cns_row_first;
481 $cns_column <= $cns_row_last;
482 ++$cns_column)
484 if ($bol == 1)
486 print OUT " ";
487 $bol = 0;
489 if (defined($cns_map[$cns_plane][$cns_row][$cns_column]))
491 $utf32 = $cns_map[$cns_plane][$cns_row][$cns_column];
492 ++$cns_row_chars;
493 if ($utf32 <= 0xFFFF)
495 printf OUT "0x%04X,", $utf32;
497 else
499 ++$cns_row_surrogates;
500 printf OUT "0x%04X,",
501 (0xD800 | (($utf32 - 0x10000) >> 10));
502 if ($cns_row_surrogates_first == -1)
504 $cns_row_surrogates_first = $cns_column;
506 $cns_row_surrogates_last = $cns_column;
509 else
511 printf OUT "0xffff,";
513 ++$cns_data_index;
514 if ($cns_column % 10 == 9)
516 print OUT "\n";
517 $bol = 1;
520 if ($bol == 0)
522 print OUT "\n";
525 if ($cns_row_surrogates_first != -1)
527 print OUT " ", $cns_row_surrogates_first,
528 ", /* first low-surrogate */\n";
529 ++$cns_data_index;
531 print OUT " ",
532 printSpaces(7, 10, $cns_row_surrogates_first);
533 $bol = 0;
534 for ($cns_column = $cns_row_surrogates_first;
535 $cns_column <= $cns_row_surrogates_last;
536 ++$cns_column)
538 if ($bol == 1)
540 print OUT " ";
541 $bol = 0;
543 $utf32 = 0;
544 if (defined($cns_map[$cns_plane]
545 [$cns_row]
546 [$cns_column]))
548 $utf32
549 = $cns_map[$cns_plane][$cns_row][$cns_column];
551 if ($utf32 <= 0xFFFF)
553 printf OUT " 0,";
555 else
557 printf OUT "0x%04X,",
558 (0xDC00
559 | (($utf32 - 0x10000) & 0x3FF));
561 ++$cns_data_index;
562 if ($cns_column % 10 == 9)
564 print OUT "\n";
565 $bol = 1;
568 if ($bol == 0)
570 print OUT "\n";
574 $cns_chars += $cns_row_chars;
575 $cns_data_space[$cns_plane][$cns_row]
576 = ($cns_data_index
577 - $cns_data_offsets[$cns_plane][$cns_row]) * 2;
578 $cns_data_used[$cns_plane][$cns_row]
579 = (1 + $cns_row_chars
580 + ($cns_row_surrogates == 0 ?
581 0 : 1 + $cns_row_surrogates)) * 2;
583 else
585 print OUT " /* plane ", $cns_plane, ", row ", $cns_row,
586 ": --- */\n";
587 $cns_data_offsets[$cns_plane][$cns_row] = -1;
590 print "cns plane ",
591 $cns_plane,
592 ": rows = ",
593 $cns_rows,
594 ", chars = ",
595 $cns_chars,
596 "\n";
599 print OUT "};\n\n";
601 print OUT "static sal_Int32 const aImpl", $id, "ToUnicodeRowOffsets[] = {\n";
602 for ($cns_plane = 1; $cns_plane <= 16; ++$cns_plane)
604 if (defined ($cns_plane_used[$cns_plane]))
606 $cns_rowoffsets_used[$cns_plane] = 0;
607 for ($cns_row = 1; $cns_row <= 94; ++$cns_row)
609 if ($cns_data_offsets[$cns_plane][$cns_row] == -1)
611 print OUT " -1, /* plane ",
612 $cns_plane,
613 ", row ",
614 $cns_row,
615 " */\n";
617 else
619 print OUT " ",
620 $cns_data_offsets[$cns_plane][$cns_row],
621 ", /* plane ",
622 $cns_plane,
623 ", row ",
624 $cns_row,
625 "; ",
626 printStats($cns_data_used[$cns_plane][$cns_row],
627 $cns_data_space[$cns_plane][$cns_row]),
628 " */\n";
629 $cns_rowoffsets_used[$cns_plane] += 4;
633 else
635 print OUT " /* plane ", $cns_plane, ": --- */\n";
638 print OUT "};\n\n";
640 print OUT "static sal_Int32 const aImpl",
641 $id,
642 "ToUnicodePlaneOffsets[] = {\n";
643 $cns_row_offset = 0;
644 for ($cns_plane = 1; $cns_plane <= 16; ++$cns_plane)
646 if (defined ($cns_plane_used[$cns_plane]))
648 print OUT " ",
649 $cns_row_offset++,
650 " * 94, /* plane ",
651 $cns_plane,
652 "; ",
653 printStats($cns_rowoffsets_used[$cns_plane], 94 * 4),
654 " */\n";
656 else
658 print OUT " -1, /* plane ", $cns_plane, " */\n";
661 print OUT "};\n\n";
663 print OUT "static sal_uInt8 const aImplUnicodeTo", $id, "Data[] = {\n";
664 $uni_data_index = 0;
665 for ($uni_plane = 0; $uni_plane <= 16; ++$uni_plane)
667 if (defined($uni_plane_used[$uni_plane]))
669 for ($uni_page = 0; $uni_page <= 255; ++$uni_page)
671 if (defined($uni_page_used[$uni_plane][$uni_page]))
673 $uni_data_offsets[$uni_plane][$uni_page] = $uni_data_index;
674 print OUT " /* plane ", $uni_plane, ", page ", $uni_page,
675 " */\n";
677 $uni_page_first = -1;
678 for ($uni_index = 0; $uni_index <= 255; ++$uni_index)
680 if (defined($uni_map[$uni_plane][$uni_page][$uni_index]))
682 if ($uni_page_first == -1)
684 $uni_page_first = $uni_index;
686 $uni_page_last = $uni_index;
690 $uni_data_used[$uni_plane][$uni_page] = 0;
692 print OUT " ", $uni_page_first, ", ", $uni_page_last,
693 ", /* first, last */\n";
694 $uni_data_index += 2;
695 $uni_data_used[$uni_plane][$uni_page] += 2;
697 print OUT " ", printSpaces(9, 8, $uni_page_first);
698 $bol = 0;
699 for ($uni_index = $uni_page_first;
700 $uni_index <= $uni_page_last;
701 ++$uni_index)
703 if ($bol == 1)
705 print OUT " ";
706 $bol = 0;
708 if (defined($uni_map[$uni_plane][$uni_page][$uni_index]))
710 $cns = $uni_map[$uni_plane][$uni_page][$uni_index];
711 printf OUT "%2d,%2d,%2d,",
712 $cns >> 16,
713 $cns >> 8 & 0xFF,
714 $cns & 0xFF;
715 $uni_data_used[$uni_plane][$uni_page] += 3;
717 else
719 print OUT " 0, 0, 0,";
721 $uni_data_index += 3;
722 if ($uni_index % 8 == 7)
724 print OUT "\n";
725 $bol = 1;
728 if ($bol == 0)
730 print OUT "\n";
733 $uni_data_space[$uni_plane][$uni_page]
734 = $uni_data_index
735 - $uni_data_offsets[$uni_plane][$uni_page];
737 else
739 $uni_data_offsets[$uni_plane][$uni_page] = -1;
740 print OUT " /* plane ", $uni_plane, ", page ", $uni_page,
741 ": --- */\n";
745 else
747 print OUT " /* plane ", $uni_plane, ": --- */\n";
750 print OUT "};\n\n";
752 print OUT "static sal_Int32 const aImplUnicodeTo", $id, "PageOffsets[] = {\n";
753 for ($uni_plane = 0; $uni_plane <= 16; ++$uni_plane)
755 if (defined($uni_plane_used[$uni_plane]))
757 $uni_pageoffsets_used[$uni_plane] = 0;
758 $uni_data_used_sum[$uni_plane] = 0;
759 $uni_data_space_sum[$uni_plane] = 0;
760 for ($uni_page = 0; $uni_page <= 255; ++$uni_page)
762 $offset = $uni_data_offsets[$uni_plane][$uni_page];
763 if ($offset == -1)
765 print OUT " -1, /* plane ",
766 $uni_plane,
767 ", page ",
768 $uni_page,
769 " */\n";
771 else
773 print OUT " ",
774 $offset,
775 ", /* plane ",
776 $uni_plane,
777 ", page ",
778 $uni_page,
779 "; ",
780 printStats($uni_data_used[$uni_plane][$uni_page],
781 $uni_data_space[$uni_plane][$uni_page]),
782 " */\n";
783 $uni_pageoffsets_used[$uni_plane] += 4;
784 $uni_data_used_sum[$uni_plane]
785 += $uni_data_used[$uni_plane][$uni_page];
786 $uni_data_space_sum[$uni_plane]
787 += $uni_data_space[$uni_plane][$uni_page];
791 else
793 print OUT " /* plane ", $uni_plane, ": --- */\n";
796 print OUT "};\n\n";
798 print OUT "static sal_Int32 const aImplUnicodeTo",
799 $id,
800 "PlaneOffsets[] = {\n";
801 $uni_page_offset = 0;
802 $uni_planeoffsets_used = 0;
803 $uni_pageoffsets_used_sum = 0;
804 $uni_pageoffsets_space_sum = 0;
805 $uni_data_used_sum2 = 0;
806 $uni_data_space_sum2 = 0;
807 for ($uni_plane = 0; $uni_plane <= 16; ++$uni_plane)
809 if (defined ($uni_plane_used[$uni_plane]))
811 print OUT " ",
812 $uni_page_offset++,
813 " * 256, /* plane ",
814 $uni_plane,
815 "; ",
816 printStats($uni_pageoffsets_used[$uni_plane], 256 * 4),
817 ", ",
818 printStats($uni_data_used_sum[$uni_plane],
819 $uni_data_space_sum[$uni_plane]),
820 " */\n";
821 $uni_planeoffsets_used += 4;
822 $uni_pageoffsets_used_sum += $uni_pageoffsets_used[$uni_plane];
823 $uni_pageoffsets_space_sum += 256 * 4;
824 $uni_data_used_sum2 += $uni_data_used_sum[$uni_plane];
825 $uni_data_space_sum2 += $uni_data_space_sum[$uni_plane];
827 else
829 print OUT " -1, /* plane ", $uni_plane, " */\n";
832 print OUT " /* ",
833 printStats($uni_planeoffsets_used, 17 * 4),
834 ", ",
835 printStats($uni_pageoffsets_used_sum, $uni_pageoffsets_space_sum),
836 ", ",
837 printStats($uni_data_used_sum2, $uni_data_space_sum2),
838 " */\n};\n";
840 close OUT;
842 print "Unihan.txt = ", $count_Unihan_txt,
843 ", CNS11643.TXT = ", $count_CNS11643_TXT,
844 ", Uni2CNS = ", $count_Uni2CNS,
845 ", total = ",
846 ($count_Unihan_txt + $count_CNS11643_TXT + $count_Uni2CNS),
847 "\n";