~ubuntu-branches/ubuntu/raring/libencode-perl/raring-proposed

« back to all changes in this revision

Viewing changes to bin/ucm2table

  • Committer: Bazaar Package Importer
  • Author(s): Jose Luis Rivas
  • Date: 2007-05-18 23:49:27 UTC
  • Revision ID: james.westby@ubuntu.com-20070518234927-bs37c807cty7i1ny
Tags: upstream-2.21
ImportĀ upstreamĀ versionĀ 2.21

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/usr/bin/perl
 
2
# $Id: ucm2table,v 2.1 2006/05/03 18:24:10 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
}