#!/usr/bin/perl use 5.006; use strict; use Getopt::Std; my %Opt; getopts("eu", \%Opt); my @Chartab; my $Hex = '[0-9A-Fa-f]'; while(<>){ chomp; my ($uni, $enc, $fb, $comment) = /^\s+(\S+)\s+\|(\d)\s+#\s+(.*)$/o or next; $comment =~ //io and next; $comment =~ /^DELETE/o and next; # print "$uni $enc $fb $comment\n"; my @byte = (); my $ord = 0; while($enc =~ /\G\\x($Hex+)/iog){ my $byte = hex($1); push @byte, $byte; $ord <<= 8; $ord += $byte; }; # print join('', @byte), " => $ord \n"; if ($Opt{u}){ $Chartab[$ord] = pack("U", hex($uni)); }else{ $Chartab[$ord] = pack("C*", @byte); } } for (my $x = 0x20; $x <= 0xffff; $ x+= 32) { my $line = ''; for my $i (0..31){ my $char = $Chartab[$x+$i]; $line .= !$char ? " " : ($x+$i < 0x7f ) ? " $char" : $char ; } $line =~ /^\s+$/o and next; printf "0x%04x: $line\n", $x; }