File: map8_bin2txt

package info (click to toggle)
libunicode-map8-perl-dfsg 0.12-3
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k, lenny
  • size: 904 kB
  • ctags: 59
  • sloc: perl: 495; ansic: 439; makefile: 45; sh: 6
file content (22 lines) | stat: -rwxr-xr-x 575 bytes parent folder | download | duplicates (7)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#!/usr/bin/perl -w

use Unicode::CharName qw(uname);

my $file = "stdin";
if (@ARGV) {
    $file = shift;
    open(STDIN, $file) || die "Can't open $file: $!\n";
}
binmode(STDIN);
die "Can't read: $!" unless read(STDIN, $magic, 4) == 4;
my($hi,$lo) = unpack("nn", $magic);
die "Bad magic\n" unless $hi == 0xFFFE && $lo == 0x0001;

print "# Made from $file (Charmap file v$lo)\n";
print "#\n";
print "# U8   Unicode     Unicode name\n";

while (read(STDIN, $buf, 4)) {
    my($from, $to) = unpack("nn", $buf);
    printf "0x%02x   0x%04x    # %s\n", $from, $to, uname($to);
}