Bump for 3.6-28
[LibreOffice.git] / sal / textenc / generate / cns116431992.pl
blob0cfd2f03a2097c933c5acd1728b5f580f23b1c30
1 #!/usr/bin/perl
2 #*************************************************************************
4 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 # Copyright 2000, 2010 Oracle and/or its affiliates.
8 # OpenOffice.org - a multi-platform office productivity suite
10 # This file is part of OpenOffice.org.
12 # OpenOffice.org is free software: you can redistribute it and/or modify
13 # it under the terms of the GNU Lesser General Public License version 3
14 # only, as published by the Free Software Foundation.
16 # OpenOffice.org is distributed in the hope that it will be useful,
17 # but WITHOUT ANY WARRANTY; without even the implied warranty of
18 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 # GNU Lesser General Public License version 3 for more details
20 # (a copy is included in the LICENSE file that accompanied this code).
22 # You should have received a copy of the GNU Lesser General Public License
23 # version 3 along with OpenOffice.org. If not, see
24 # <http://www.openoffice.org/license.html>
25 # for a copy of the LGPLv3 License.
27 #*************************************************************************
29 # The following files must be available in a ./input subdir:
31 # <http://www.unicode.org/Public/UNIDATA/Unihan.txt>:
32 # "Unicode version: 3.1.1 Table version: 1.1 Date: 28 June 2001"
33 # contains descriptions for:
34 # U+3400..4DFF CJK Unified Ideographs Extension A
35 # U+4E00..9FFF CJK Unified Ideographs
36 # U+F900..FAFF CJK Compatibility Ideographs
37 # U+20000..2F7FF CJK Unified Ideographs Extension B
38 # U+2F800..2FFFF CJK Compatibility Ideographs Supplement
40 # <http://www.unicode.org/Public/MAPPINGS/OBSOLETE/EASTASIA/CNS11643.TXT>:
41 # "Unicode version: 1.1 Table version: 0.0d1 Date: 21 October 1994"
42 # contains mappings for CNS 11643-1986
44 # <http://kanji.zinbun.kyoto-u.ac.jp/~yasuoka/ftp/CJKtable/Uni2CNS.Z>:
45 # "Unicode version: 1.1 Table version: 0.49 Date: 26 March 1998"
46 # contains mappings for CNS 11643-1992 that are incompatible with
47 # CNS11643.TXT
49 $id = "Cns116431992";
51 sub isValidUtf32
53 my $utf32 = $_[0];
54 return $utf32 >= 0 && $utf32 <= 0x10FFFF
55 && !($utf32 >= 0xD800 && $utf32 <= 0xDFFF)
56 && !($utf32 >= 0xFDD0 && $utf32 <= 0xFDEF)
57 && ($utf32 & 0xFFFF) < 0xFFFE;
60 sub printUtf32
62 my $utf32 = $_[0];
63 return sprintf("U+%04X", $utf32);
66 sub isValidCns116431992
68 my $plane = $_[0];
69 my $row = $_[1];
70 my $column = $_[2];
71 return $plane >= 1 && $plane <= 16
72 && $row >= 1 && $row <= 94
73 && $column >= 1 && $column <= 94;
76 sub printCns116431992
78 my $plane = $_[0];
79 my $row = $_[1];
80 my $column = $_[2];
81 return sprintf("%d-%02d/%02d", $plane, $row, $column);
84 sub printStats
86 my $used = $_[0];
87 my $space = $_[1];
88 return sprintf("%d/%d bytes (%.1f%%)",
89 $used,
90 $space,
91 $used * 100 / $space);
94 sub printSpaces
96 my $column_width = $_[0];
97 my $columns_per_line = $_[1];
98 my $end = $_[2];
99 $output = "";
100 for ($i = int($end / $columns_per_line) * $columns_per_line;
101 $i < $end;
102 ++$i)
104 for ($j = 0; $j < $column_width; ++$j)
106 $output = $output . " ";
109 return $output;
112 $count_Unihan_txt = 0;
113 $count_CNS11643_TXT = 0;
114 $count_Uni2CNS = 0;
116 if (1)
118 $filename = "Unihan.txt";
119 open IN, ("input/" . $filename) or die "Cannot read " . $filename;
120 while (<IN>)
122 if (/^U\+([0-9A-F]+)\tkCNS1992\t([0-9A-F])-([0-9A-F][0-9A-F])([0-9A-F][0-9A-F])$/)
124 $utf32 = oct("0x" . $1);
125 $cns_plane = oct("0x" . $2);
126 $cns_row = oct("0x" . $3) - 0x20;
127 $cns_column = oct("0x" . $4) - 0x20;
128 isValidUtf32($utf32)
129 or die "Bad UTF32 char U+" . printUtf32($utf32);
130 isValidCns116431992($cns_plane, $cns_row, $cns_column)
131 or die "Bad CNS11643-1992 char "
132 . printCns116431992($cns_plane,
133 $cns_row,
134 $cns_column);
135 if (!defined($cns_map[$cns_plane][$cns_row][$cns_column]))
137 $cns_map[$cns_plane][$cns_row][$cns_column] = $utf32;
138 $cns_plane_used[$cns_plane] = 1;
139 ++$count_Unihan_txt;
141 else
143 ($cns_map[$cns_plane][$cns_row][$cns_column] == $utf32)
144 or die "Mapping "
145 . printCns116431992($cns_plane,
146 $cns_row,
147 $cns_column)
148 . " to "
149 . printUtf32($cns_map[$cns_plane]
150 [$cns_row]
151 [$cns_column])
152 . ", NOT "
153 . printUtf32($utf32);
156 elsif (/^U\+([0-9A-F]+)\tkIRG_TSource\t([0-9A-F])-([0-9A-F][0-9A-F])([0-9A-F][0-9A-F])$/)
158 $utf32 = oct("0x" . $1);
159 $cns_plane = oct("0x" . $2);
160 $cns_row = oct("0x" . $3) - 0x20;
161 $cns_column = oct("0x" . $4) - 0x20;
162 isValidUtf32($utf32)
163 or die "Bad UTF32 char U+" . printUtf32($utf32);
164 isValidCns116431992($cns_plane, $cns_row, $cns_column)
165 or die "Bad CNS11643-1992 char "
166 . printCns116431992($cns_plane,
167 $cns_row,
168 $cns_column);
169 if (!defined($cns_map[$cns_plane][$cns_row][$cns_column]))
171 $cns_map[$cns_plane][$cns_row][$cns_column] = $utf32;
172 $cns_plane_used[$cns_plane] = 1;
173 ++$count_Unihan_txt;
175 else
177 ($cns_map[$cns_plane][$cns_row][$cns_column] == $utf32)
178 or print "WARNING! Mapping ",
179 printCns116431992($cns_plane,
180 $cns_row,
181 $cns_column),
182 " to ",
183 printUtf32($cns_map[$cns_plane]
184 [$cns_row]
185 [$cns_column]),
186 ", NOT ",
187 printUtf32($utf32),
188 "\n";
191 elsif (/^U\+([0-9A-F]+)\tkCNS1992\t.*$/)
193 die "Bad format";
196 close IN;
199 if (1)
201 $filename = "CNS11643.TXT";
202 open IN, ("input/" . $filename) or die "Cannot read " . $filename;
203 while (<IN>)
205 if (/0x([0-9A-F])([0-9A-F][0-9A-F])([0-9A-F][0-9A-F])\t0x([0-9A-F]+)\t\#.*$/)
207 $utf32 = oct("0x" . $4);
208 $cns_plane = oct("0x" . $1);
209 $cns_row = oct("0x" . $2) - 0x20;
210 $cns_column = oct("0x" . $3) - 0x20;
211 isValidUtf32($utf32)
212 or die "Bad UTF32 char U+" . printUtf32($utf32);
213 isValidCns116431992($cns_plane, $cns_row, $cns_column)
214 or die "Bad CNS11643-1992 char "
215 . printCns116431992($cns_plane,
216 $cns_row,
217 $cns_column);
218 if ($cns_plane <= 2)
220 if (!defined($cns_map[$cns_plane][$cns_row][$cns_column]))
222 $cns_map[$cns_plane][$cns_row][$cns_column] = $utf32;
223 $cns_plane_used[$cns_plane] = 1;
224 ++$count_CNS11643_TXT;
226 else
228 ($cns_map[$cns_plane][$cns_row][$cns_column] == $utf32)
229 or die "Mapping "
230 . printCns116431992($cns_plane,
231 $cns_row,
232 $cns_column)
233 . " to "
234 . printUtf32($cns_map[$cns_plane]
235 [$cns_row]
236 [$cns_column])
237 . ", NOT "
238 . printUtf32($utf32);
243 close IN;
246 if (0)
248 $filename = "Uni2CNS";
249 open IN, ("input/" . $filename) or die "Cannot read " . $filename;
250 while (<IN>)
252 if (/([0-9A-F]+)\t([0-9A-F])-([0-9A-F][0-9A-F])([0-9A-F][0-9A-F])\t.*$/)
254 $utf32 = oct("0x" . $1);
255 $cns_plane = oct("0x" . $2);
256 $cns_row = oct("0x" . $3) - 0x20;
257 $cns_column = oct("0x" . $4) - 0x20;
258 isValidUtf32($utf32)
259 or die "Bad UTF32 char U+" . printUtf32($utf32);
260 isValidCns116431992($cns_plane, $cns_row, $cns_column)
261 or die "Bad CNS11643-1992 char "
262 . printCns116431992($cns_plane,
263 $cns_row,
264 $cns_column);
265 if (!defined($cns_map[$cns_plane][$cns_row][$cns_column]))
267 $cns_map[$cns_plane][$cns_row][$cns_column] = $utf32;
268 $cns_plane_used[$cns_plane] = 1;
269 ++$count_Uni2CNS;
271 else
273 # ($cns_map[$cns_plane][$cns_row][$cns_column] == $utf32)
274 # or die "Mapping "
275 # . printCns116431992($cns_plane,
276 # $cns_row,
277 # $cns_column)
278 # . " to "
279 # . printUtf32($cns_map[$cns_plane]
280 # [$cns_row]
281 # [$cns_column])
282 # . ", NOT "
283 # . printUtf32($utf32);
285 if ($cns_plane == 1)
287 print printCns116431992($cns_plane, $cns_row, $cns_column),
288 "\n";
292 close IN;
295 for ($cns_plane = 1; $cns_plane <= 16; ++$cns_plane)
297 if (defined($cns_plane_used[$cns_plane]))
299 for ($cns_row = 1; $cns_row <= 94; ++$cns_row)
301 for ($cns_column = 1; $cns_column <= 94; ++$cns_column)
303 if (defined($cns_map[$cns_plane][$cns_row][$cns_column]))
305 $utf32 = $cns_map[$cns_plane][$cns_row][$cns_column];
306 $uni_plane = $utf32 >> 16;
307 $uni_page = ($utf32 >> 8) & 0xFF;
308 $uni_index = $utf32 & 0xFF;
309 if (!defined($uni_plane_used[$uni_plane])
310 || !defined($uni_page_used[$uni_plane][$uni_page])
311 || !defined($uni_map[$uni_plane]
312 [$uni_page]
313 [$uni_index]))
315 $uni_map[$uni_plane][$uni_page][$uni_index]
316 = ($cns_plane << 16)
317 | ($cns_row << 8)
318 | $cns_column;
319 $uni_plane_used[$uni_plane] = 1;
320 $uni_page_used[$uni_plane][$uni_page] = 1;
322 else
324 $cns1 = $uni_map[$uni_plane][$uni_page][$uni_index];
325 $cns1_plane = $cns1 >> 16;
326 $cns1_row = ($cns1 >> 8) & 0xFF;
327 $cns1_column = $cns1 & 0xFF;
329 # Do not map from Unicode to Fictious Character Set
330 # Extensions (Lunde, p. 131), if possible:
331 if ($cns_plane == 3
332 && ($cns_row == 66 && $cns_column > 38
333 || $cns_row > 66))
335 print " (",
336 printUtf32($utf32),
337 " to fictious ",
338 printCns116431992($cns_plane,
339 $cns_row,
340 $cns_column),
341 " ignored, favouring ",
342 printCns116431992($cns1_plane,
343 $cns1_row,
344 $cns1_column),
345 ")\n";
347 elsif ($cns1_plane == 3
348 && ($cns1_row == 66 && $cns1_column > 38
349 || $cns1_row > 66))
351 $uni_map[$uni_plane][$uni_page][$uni_index]
352 = ($cns_plane << 16)
353 | ($cns_row << 8)
354 | $cns_column;
355 print " (",
356 printUtf32($utf32),
357 " to fictious ",
358 printCns116431992($cns1_plane,
359 $cns1_row,
360 $cns1_column),
361 " ignored, favouring ",
362 printCns116431992($cns_plane,
363 $cns_row,
364 $cns_column),
365 ")\n";
367 else
369 print "WARNING! Mapping ",
370 printUtf32($utf32),
371 " to ",
372 printCns116431992($cns1_plane,
373 $cns1_row,
374 $cns1_column),
375 ", NOT ",
376 printCns116431992($cns_plane,
377 $cns_row,
378 $cns_column),
379 "\n";
387 if (defined($uni_plane_used[0]) && defined($uni_page_used[0][0]))
389 for ($utf32 = 0; $utf32 <= 0x7F; ++$utf32)
391 if (defined($uni_map[0][0][$uni_index]))
393 $cns = $uni_map[0][0][$utf32];
394 die "Mapping "
395 . printUtf32($utf32)
396 . " to "
397 . printCns116431992($cns >> 16,
398 ($cns >> 8) & 0xFF,
399 $cns & 0xFF);
404 $filename = lc($id) . ".tab";
405 open OUT, ("> " . $filename) or die "Cannot write " . $filename;
408 $filename = lc($id). ".pl";
409 open IN, $filename or die "Cannot read ". $filename;
410 $first = 1;
411 while (<IN>)
413 if (/^\#!.*$/)
416 elsif (/^\#(\*.*)$/)
418 if ($first == 1)
420 print OUT "/", $1, "\n";
421 $first = 0;
423 else
425 print OUT " ", substr($1, 0, length($1) - 1), "/\n";
428 elsif (/^\# (.*)$/)
430 print OUT " *", $1, "\n";
432 elsif (/^\#(.*)$/)
434 print OUT " *", $1, "\n";
436 else
438 goto done;
441 done:
444 print OUT "\n",
445 "#ifndef _SAL_TYPES_H_\n",
446 "#include \"sal/types.h\"\n",
447 "#endif\n",
448 "\n";
450 print OUT "static sal_uInt16 const aImpl", $id, "ToUnicodeData[] = {\n";
451 $cns_data_index = 0;
452 for ($cns_plane = 1; $cns_plane <= 16; ++$cns_plane)
454 if (defined($cns_plane_used[$cns_plane]))
456 $cns_rows = 0;
457 $cns_chars = 0;
458 for ($cns_row = 1; $cns_row <= 94; ++$cns_row)
460 $cns_row_first = -1;
461 for ($cns_column = 1; $cns_column <= 94; ++$cns_column)
463 if (defined($cns_map[$cns_plane][$cns_row][$cns_column]))
465 if ($cns_row_first == -1)
467 $cns_row_first = $cns_column;
469 $cns_row_last = $cns_column;
472 if ($cns_row_first != -1)
474 $cns_data_offsets[$cns_plane][$cns_row] = $cns_data_index;
475 ++$cns_rows;
476 print OUT " /* plane ", $cns_plane, ", row ", $cns_row,
477 " */\n";
479 $cns_row_surrogates_first = -1;
480 $cns_row_chars = 0;
481 $cns_row_surrogates = 0;
483 print OUT " ", $cns_row_first, " | (", $cns_row_last,
484 " << 8), /* first, last */\n";
485 ++$cns_data_index;
487 print OUT " ", printSpaces(7, 10, $cns_row_first);
488 $bol = 0;
489 for ($cns_column = $cns_row_first;
490 $cns_column <= $cns_row_last;
491 ++$cns_column)
493 if ($bol == 1)
495 print OUT " ";
496 $bol = 0;
498 if (defined($cns_map[$cns_plane][$cns_row][$cns_column]))
500 $utf32 = $cns_map[$cns_plane][$cns_row][$cns_column];
501 ++$cns_row_chars;
502 if ($utf32 <= 0xFFFF)
504 printf OUT "0x%04X,", $utf32;
506 else
508 ++$cns_row_surrogates;
509 printf OUT "0x%04X,",
510 (0xD800 | (($utf32 - 0x10000) >> 10));
511 if ($cns_row_surrogates_first == -1)
513 $cns_row_surrogates_first = $cns_column;
515 $cns_row_surrogates_last = $cns_column;
518 else
520 printf OUT "0xffff,";
522 ++$cns_data_index;
523 if ($cns_column % 10 == 9)
525 print OUT "\n";
526 $bol = 1;
529 if ($bol == 0)
531 print OUT "\n";
534 if ($cns_row_surrogates_first != -1)
536 print OUT " ", $cns_row_surrogates_first,
537 ", /* first low-surrogate */\n";
538 ++$cns_data_index;
540 print OUT " ",
541 printSpaces(7, 10, $cns_row_surrogates_first);
542 $bol = 0;
543 for ($cns_column = $cns_row_surrogates_first;
544 $cns_column <= $cns_row_surrogates_last;
545 ++$cns_column)
547 if ($bol == 1)
549 print OUT " ";
550 $bol = 0;
552 $utf32 = 0;
553 if (defined($cns_map[$cns_plane]
554 [$cns_row]
555 [$cns_column]))
557 $utf32
558 = $cns_map[$cns_plane][$cns_row][$cns_column];
560 if ($utf32 <= 0xFFFF)
562 printf OUT " 0,";
564 else
566 printf OUT "0x%04X,",
567 (0xDC00
568 | (($utf32 - 0x10000) & 0x3FF));
570 ++$cns_data_index;
571 if ($cns_column % 10 == 9)
573 print OUT "\n";
574 $bol = 1;
577 if ($bol == 0)
579 print OUT "\n";
583 $cns_chars += $cns_row_chars;
584 $cns_data_space[$cns_plane][$cns_row]
585 = ($cns_data_index
586 - $cns_data_offsets[$cns_plane][$cns_row]) * 2;
587 $cns_data_used[$cns_plane][$cns_row]
588 = (1 + $cns_row_chars
589 + ($cns_row_surrogates == 0 ?
590 0 : 1 + $cns_row_surrogates)) * 2;
592 else
594 print OUT " /* plane ", $cns_plane, ", row ", $cns_row,
595 ": --- */\n";
596 $cns_data_offsets[$cns_plane][$cns_row] = -1;
599 print "cns plane ",
600 $cns_plane,
601 ": rows = ",
602 $cns_rows,
603 ", chars = ",
604 $cns_chars,
605 "\n";
608 print OUT "};\n\n";
610 print OUT "static sal_Int32 const aImpl", $id, "ToUnicodeRowOffsets[] = {\n";
611 for ($cns_plane = 1; $cns_plane <= 16; ++$cns_plane)
613 if (defined ($cns_plane_used[$cns_plane]))
615 $cns_rowoffsets_used[$cns_plane] = 0;
616 for ($cns_row = 1; $cns_row <= 94; ++$cns_row)
618 if ($cns_data_offsets[$cns_plane][$cns_row] == -1)
620 print OUT " -1, /* plane ",
621 $cns_plane,
622 ", row ",
623 $cns_row,
624 " */\n";
626 else
628 print OUT " ",
629 $cns_data_offsets[$cns_plane][$cns_row],
630 ", /* plane ",
631 $cns_plane,
632 ", row ",
633 $cns_row,
634 "; ",
635 printStats($cns_data_used[$cns_plane][$cns_row],
636 $cns_data_space[$cns_plane][$cns_row]),
637 " */\n";
638 $cns_rowoffsets_used[$cns_plane] += 4;
642 else
644 print OUT " /* plane ", $cns_plane, ": --- */\n";
647 print OUT "};\n\n";
649 print OUT "static sal_Int32 const aImpl",
650 $id,
651 "ToUnicodePlaneOffsets[] = {\n";
652 $cns_row_offset = 0;
653 for ($cns_plane = 1; $cns_plane <= 16; ++$cns_plane)
655 if (defined ($cns_plane_used[$cns_plane]))
657 print OUT " ",
658 $cns_row_offset++,
659 " * 94, /* plane ",
660 $cns_plane,
661 "; ",
662 printStats($cns_rowoffsets_used[$cns_plane], 94 * 4),
663 " */\n";
665 else
667 print OUT " -1, /* plane ", $cns_plane, " */\n";
670 print OUT "};\n\n";
672 print OUT "static sal_uInt8 const aImplUnicodeTo", $id, "Data[] = {\n";
673 $uni_data_index = 0;
674 for ($uni_plane = 0; $uni_plane <= 16; ++$uni_plane)
676 if (defined($uni_plane_used[$uni_plane]))
678 for ($uni_page = 0; $uni_page <= 255; ++$uni_page)
680 if (defined($uni_page_used[$uni_plane][$uni_page]))
682 $uni_data_offsets[$uni_plane][$uni_page] = $uni_data_index;
683 print OUT " /* plane ", $uni_plane, ", page ", $uni_page,
684 " */\n";
686 $uni_page_first = -1;
687 for ($uni_index = 0; $uni_index <= 255; ++$uni_index)
689 if (defined($uni_map[$uni_plane][$uni_page][$uni_index]))
691 if ($uni_page_first == -1)
693 $uni_page_first = $uni_index;
695 $uni_page_last = $uni_index;
699 $uni_data_used[$uni_plane][$uni_page] = 0;
701 print OUT " ", $uni_page_first, ", ", $uni_page_last,
702 ", /* first, last */\n";
703 $uni_data_index += 2;
704 $uni_data_used[$uni_plane][$uni_page] += 2;
706 print OUT " ", printSpaces(9, 8, $uni_page_first);
707 $bol = 0;
708 for ($uni_index = $uni_page_first;
709 $uni_index <= $uni_page_last;
710 ++$uni_index)
712 if ($bol == 1)
714 print OUT " ";
715 $bol = 0;
717 if (defined($uni_map[$uni_plane][$uni_page][$uni_index]))
719 $cns = $uni_map[$uni_plane][$uni_page][$uni_index];
720 printf OUT "%2d,%2d,%2d,",
721 $cns >> 16,
722 $cns >> 8 & 0xFF,
723 $cns & 0xFF;
724 $uni_data_used[$uni_plane][$uni_page] += 3;
726 else
728 print OUT " 0, 0, 0,";
730 $uni_data_index += 3;
731 if ($uni_index % 8 == 7)
733 print OUT "\n";
734 $bol = 1;
737 if ($bol == 0)
739 print OUT "\n";
742 $uni_data_space[$uni_plane][$uni_page]
743 = $uni_data_index
744 - $uni_data_offsets[$uni_plane][$uni_page];
746 else
748 $uni_data_offsets[$uni_plane][$uni_page] = -1;
749 print OUT " /* plane ", $uni_plane, ", page ", $uni_page,
750 ": --- */\n";
754 else
756 print OUT " /* plane ", $uni_plane, ": --- */\n";
759 print OUT "};\n\n";
761 print OUT "static sal_Int32 const aImplUnicodeTo", $id, "PageOffsets[] = {\n";
762 for ($uni_plane = 0; $uni_plane <= 16; ++$uni_plane)
764 if (defined($uni_plane_used[$uni_plane]))
766 $uni_pageoffsets_used[$uni_plane] = 0;
767 $uni_data_used_sum[$uni_plane] = 0;
768 $uni_data_space_sum[$uni_plane] = 0;
769 for ($uni_page = 0; $uni_page <= 255; ++$uni_page)
771 $offset = $uni_data_offsets[$uni_plane][$uni_page];
772 if ($offset == -1)
774 print OUT " -1, /* plane ",
775 $uni_plane,
776 ", page ",
777 $uni_page,
778 " */\n";
780 else
782 print OUT " ",
783 $offset,
784 ", /* plane ",
785 $uni_plane,
786 ", page ",
787 $uni_page,
788 "; ",
789 printStats($uni_data_used[$uni_plane][$uni_page],
790 $uni_data_space[$uni_plane][$uni_page]),
791 " */\n";
792 $uni_pageoffsets_used[$uni_plane] += 4;
793 $uni_data_used_sum[$uni_plane]
794 += $uni_data_used[$uni_plane][$uni_page];
795 $uni_data_space_sum[$uni_plane]
796 += $uni_data_space[$uni_plane][$uni_page];
800 else
802 print OUT " /* plane ", $uni_plane, ": --- */\n";
805 print OUT "};\n\n";
807 print OUT "static sal_Int32 const aImplUnicodeTo",
808 $id,
809 "PlaneOffsets[] = {\n";
810 $uni_page_offset = 0;
811 $uni_planeoffsets_used = 0;
812 $uni_pageoffsets_used_sum = 0;
813 $uni_pageoffsets_space_sum = 0;
814 $uni_data_used_sum2 = 0;
815 $uni_data_space_sum2 = 0;
816 for ($uni_plane = 0; $uni_plane <= 16; ++$uni_plane)
818 if (defined ($uni_plane_used[$uni_plane]))
820 print OUT " ",
821 $uni_page_offset++,
822 " * 256, /* plane ",
823 $uni_plane,
824 "; ",
825 printStats($uni_pageoffsets_used[$uni_plane], 256 * 4),
826 ", ",
827 printStats($uni_data_used_sum[$uni_plane],
828 $uni_data_space_sum[$uni_plane]),
829 " */\n";
830 $uni_planeoffsets_used += 4;
831 $uni_pageoffsets_used_sum += $uni_pageoffsets_used[$uni_plane];
832 $uni_pageoffsets_space_sum += 256 * 4;
833 $uni_data_used_sum2 += $uni_data_used_sum[$uni_plane];
834 $uni_data_space_sum2 += $uni_data_space_sum[$uni_plane];
836 else
838 print OUT " -1, /* plane ", $uni_plane, " */\n";
841 print OUT " /* ",
842 printStats($uni_planeoffsets_used, 17 * 4),
843 ", ",
844 printStats($uni_pageoffsets_used_sum, $uni_pageoffsets_space_sum),
845 ", ",
846 printStats($uni_data_used_sum2, $uni_data_space_sum2),
847 " */\n};\n";
849 close OUT;
851 print "Unihan.txt = ", $count_Unihan_txt,
852 ", CNS11643.TXT = ", $count_CNS11643_TXT,
853 ", Uni2CNS = ", $count_Uni2CNS,
854 ", total = ",
855 ($count_Unihan_txt + $count_CNS11643_TXT + $count_Uni2CNS),
856 "\n";