]> mj.ucw.cz Git - libucw.git/blob - charset/misc/enc2table
Rewrote to use pread/pwrite() and to avoid messing up with internals
[libucw.git] / charset / misc / enc2table
1 #!/usr/bin/perl
2 #
3 #  Convert ".enc" file from the CStoCS package to UCS-2 character mapping
4 #  (c) 1997 Martin Mares <mj@atrey.karlin.mff.cuni.cz>
5 #
6
7 open (MAP, "cstocs-names") || die "No charname file";
8 while (<MAP>) {
9         chop;
10         ($c,$uni) = split /[ \t]+/;
11 #       if (defined $um{$uni}) { print "Warning: $uni redefined\n"; }
12         $um{$uni} = $c;
13         $code{$c} = $uni;
14 }
15 close MAP;
16
17 while (<>) {
18         chop;
19         ($_,$c,$name) = split /[\t ]+/;
20         if ($c >= 128) {
21                 if (!defined $code{$name}) { die "$name unknown"; }
22                 $u{$c} = $code{$name};
23         }
24 }
25
26 for ($i=0; $i<256; $i++) {
27         $v = (defined $u{$i}) ? $u{$i} : ($i < 128 ? sprintf("%04X", $i) : "FFFD");
28         printf "%02X\t%s\n", $i, $v;
29 }