ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/cvsroot/staticperl/perl/ext/Encode/bin/ucm2table
Revision: 1.1
Committed: Thu Jun 30 14:26:47 2005 UTC (21 years, 3 months ago) by root
Branch: MAIN
CVS Tags: HEAD
Branch point for: PERL
Log Message:
*** empty log message ***

File Contents

# Content
1 #!/usr/bin/perl
2 # $Id: ucm2table,v 2.0 2004/05/16 20:55:16 dankogai Exp $
3 #
4
5 use 5.006;
6 use strict;
7 use Getopt::Std;
8 my %Opt;
9 getopts("aeu", \%Opt);
10 my %Chartab;
11
12 my $Hex = '[0-9A-Fa-f]';
13 while(<>){
14 chomp;
15 my ($uni, $enc, $fb) =
16 /^<U($Hex+)>\s+(\S+)\s+\|(\d)/o or next;
17 $fb eq '0' or next;
18 my @byte = ();
19 my $ord = 0;
20 while($enc =~ /\G\\x($Hex+)/iog){
21 my $byte = hex($1);
22 push @byte, $byte;
23 $ord <<= 8; $ord += $byte;
24 };
25 # print join('', @byte), " => $ord \n";
26 if ($Opt{u}){
27 $Chartab{$ord} = pack("U", hex($uni));
28 }else{
29 $Chartab{$ord} = pack("C*", @byte);
30 }
31 }
32
33 my $start = $Opt{a} ? 0x20 : 0xa0;
34
35 for (my $x = $start; $x <= 0xffff; $x += 32) {
36 my $line = '';
37 for my $i (0..31){
38 my $num = $x+$i; $num eq 0x7f and next; # skip delete
39 my $char = $Chartab{$num};
40 $line .= !$char ? " " :
41 ($num < 0x7f ) ? " $char" : $char ;
42 }
43 $line =~ /^\s+$/o and next;
44 printf "0x%04x: $line\n", $x;
45 }