Back to home page

OSCL-LXR

 
 

    


0001 #!/usr/bin/perl -w
0002 #
0003 # winucase_convert.pl -- convert "Windows 8 Upper Case Mapping Table.txt" to
0004 #                        a two-level set of C arrays.
0005 #
0006 #   Copyright 2013: Jeff Layton <jlayton@redhat.com>
0007 #
0008 #   This program is free software: you can redistribute it and/or modify
0009 #   it under the terms of the GNU General Public License as published by
0010 #   the Free Software Foundation, either version 3 of the License, or
0011 #   (at your option) any later version.
0012 #
0013 #   This program is distributed in the hope that it will be useful,
0014 #   but WITHOUT ANY WARRANTY; without even the implied warranty of
0015 #   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
0016 #   GNU General Public License for more details.
0017 #
0018 #   You should have received a copy of the GNU General Public License
0019 #   along with this program.  If not, see <https://www.gnu.org/licenses/>.
0020 #
0021 
0022 while(<>) {
0023     next if (!/^0x(..)(..)\t0x(....)\t/);
0024     $firstchar = hex($1);
0025     $secondchar = hex($2);
0026     $uppercase = hex($3);
0027 
0028     $top[$firstchar][$secondchar] = $uppercase;
0029 }
0030 
0031 for ($i = 0; $i < 256; $i++) {
0032     next if (!$top[$i]);
0033 
0034     printf("static const wchar_t t2_%2.2x[256] = {", $i);
0035     for ($j = 0; $j < 256; $j++) {
0036         if (($j % 8) == 0) {
0037             print "\n\t";
0038         } else {
0039             print " ";
0040         }
0041         printf("0x%4.4x,", $top[$i][$j] ? $top[$i][$j] : 0);
0042     }
0043     print "\n};\n\n";
0044 }
0045 
0046 printf("static const wchar_t *const toplevel[256] = {", $i);
0047 for ($i = 0; $i < 256; $i++) {
0048     if (($i % 8) == 0) {
0049         print "\n\t";
0050     } elsif ($top[$i]) {
0051         print " ";
0052     } else {
0053         print "  ";
0054     }
0055 
0056     if ($top[$i]) {
0057         printf("t2_%2.2x,", $i);
0058     } else {
0059         print "NULL,";
0060     }
0061 }
0062 print "\n};\n\n";