/[suikacvs]/perl/lib/Encode/Table/tool/tbl2ucm.pl
Suika

Contents of /perl/lib/Encode/Table/tool/tbl2ucm.pl

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.2 - (hide annotations) (download)
Sat Oct 5 01:34:55 2002 UTC (22 years, 2 months ago) by wakaba
Branch: MAIN
Changes since 1.1: +31 -0 lines
File MIME type: text/plain
2002-10-05  Nanashi-san

	* Table.pm: New module.
	(Commited by Wakaba <w@suika.fam.cx>.)

1 wakaba 1.1 #!/usr/bin/perl
2     use strict;
3    
4 wakaba 1.2 =head1 NAME
5    
6     tbl2ucm --- PETBL/1.0 -> ucm converter
7    
8     =cut
9    
10 wakaba 1.1 my @l;
11     my %i;
12     while (<>) {
13     if (/^0x([0-9A-F]+)\tU\+([0-9A-F]+)\t([^\t]*)\t# ?(.*)/) {
14     push @l, {local => hex $1, ucs => hex $2, comment => $4};
15     my $info = $3;
16     if ($info =~ /<->/) { $l[-1]->{fallback} = 0 }
17     elsif ($info =~ /<-/) { $l[-1]->{fallback} = 1 }
18     elsif ($info =~ /->/) { $l[-1]->{fallback} = 3 }
19     } elsif (/^## ([a-z0-9:_-]+)\t(.+)/) {
20     $i{$1} = $2;
21     }
22     }
23    
24     @l = sort { $a->{ucs} <=> $b->{ucs} || $a->{fallback} <=> $b->{fallback} || $a->{local} <=> $b->{local} } @l;
25    
26     print <<EOH;
27     #
28     <code_set_name> "@{[ $i{'ucm:code_set_name'} || $i{name} ]}"
29     @{[&{sub{
30     my $s = '';
31     for (sort split /\t/, $i{'ucm:code_set_alias'}) {
32     $s .= sprintf '<code_set_alias> "%s"%s', $_, "\n";
33     }
34     $s;
35     }}]}<mb_cur_min> @{[ $i{'ucm:mb_cur_min'} || 1 ]}
36     <mb_cur_max> @{[ $i{'ucm:mb_cur_max'} || 1 ]}
37     <subchar> @{[&{sub{
38     my $s = uc $i{'ucm:subchar'}|| $i{'<-ucs-substition'} || $i{substition} || '0x3F';
39     $s =~ s/^[0\\]X/\\x/;
40     $s =~ s/^\\x([0-9A-F][0-9A-F])([0-9A-F][0-9A-F])/\\x$1\\x$2/;
41     $s;
42     }}]}
43     #
44     CHARMAP
45     EOH
46    
47     for (@l) {
48     printf q{<U%04X> \x%02X |%d # %s}, $_->{ucs}, $_->{local}, $_->{fallback}, $_->{comment}."\n";
49     }
50    
51     print "END CHARMAP\n";
52 wakaba 1.2
53    
54     =head1 SEE ALSO
55    
56     perlunicode, enc2xs, tbr2tbl.pl
57    
58     =head1 AUTHOR
59    
60     Nanashi-san
61    
62     =head1 LICENSE
63    
64     Copyright 2002 AUTHOR
65    
66     This library is free software; you can redistribute it
67     and/or modify it under the same terms as Perl itself.
68    
69     AUTHOR does NOT claim any right to the data generated by
70     this script. License of generated data fully depends
71     author of source data.
72    
73     =cut
74    
75     1; ## $Date: 2002/10/05 00:25:14 $
76     ### tbl2ucm.pl ends here

admin@suikawiki.org
ViewVC Help
Powered by ViewVC 1.1.24