source: trunk/essentials/dev-lang/perl/ext/Encode/bin/ucm2table

Last change on this file was 3181, checked in by bird, 19 years ago

perl 5.8.8

File size: 954 bytes
Line 
1#!/usr/bin/perl
2# $Id: ucm2table,v 2.0 2004/05/16 20:55:16 dankogai Exp $
3#
4
5use 5.006;
6use strict;
7use Getopt::Std;
8my %Opt;
9getopts("aeu", \%Opt);
10my %Chartab;
11
12my $Hex = '[0-9A-Fa-f]';
13while(<>){
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
33my $start = $Opt{a} ? 0x20 : 0xa0;
34
35for (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}
Note: See TracBrowser for help on using the repository browser.