Path: blob/master/Documentation/admin-guide/cifs/winucase_convert.pl
26285 views
#!/usr/bin/perl -w1#2# winucase_convert.pl -- convert "Windows 8 Upper Case Mapping Table.txt" to3# a two-level set of C arrays.4#5# Copyright 2013: Jeff Layton <[email protected]>6#7# This program is free software: you can redistribute it and/or modify8# it under the terms of the GNU General Public License as published by9# the Free Software Foundation, either version 3 of the License, or10# (at your option) any later version.11#12# This program is distributed in the hope that it will be useful,13# but WITHOUT ANY WARRANTY; without even the implied warranty of14# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the15# GNU General Public License for more details.16#17# You should have received a copy of the GNU General Public License18# along with this program. If not, see <https://www.gnu.org/licenses/>.19#2021while(<>) {22next if (!/^0x(..)(..)\t0x(....)\t/);23$firstchar = hex($1);24$secondchar = hex($2);25$uppercase = hex($3);2627$top[$firstchar][$secondchar] = $uppercase;28}2930for ($i = 0; $i < 256; $i++) {31next if (!$top[$i]);3233printf("static const wchar_t t2_%2.2x[256] = {", $i);34for ($j = 0; $j < 256; $j++) {35if (($j % 8) == 0) {36print "\n\t";37} else {38print " ";39}40printf("0x%4.4x,", $top[$i][$j] ? $top[$i][$j] : 0);41}42print "\n};\n\n";43}4445printf("static const wchar_t *const toplevel[256] = {", $i);46for ($i = 0; $i < 256; $i++) {47if (($i % 8) == 0) {48print "\n\t";49} elsif ($top[$i]) {50print " ";51} else {52print " ";53}5455if ($top[$i]) {56printf("t2_%2.2x,", $i);57} else {58print "NULL,";59}60}61print "\n};\n\n";626364