| 1 |
wakaba |
1.1 |
#!/usr/bin/perl
|
| 2 |
|
|
use strict;
|
| 3 |
|
|
|
| 4 |
|
|
my @l;
|
| 5 |
|
|
my %i;
|
| 6 |
|
|
while (<>) {
|
| 7 |
|
|
if (/^0x([0-9A-F]+)\tU\+([0-9A-F]+)\t([^\t]*)\t# ?(.*)/) {
|
| 8 |
|
|
push @l, {local => hex $1, ucs => hex $2, comment => $4};
|
| 9 |
|
|
my $info = $3;
|
| 10 |
|
|
if ($info =~ /<->/) { $l[-1]->{fallback} = 0 }
|
| 11 |
|
|
elsif ($info =~ /<-/) { $l[-1]->{fallback} = 1 }
|
| 12 |
|
|
elsif ($info =~ /->/) { $l[-1]->{fallback} = 3 }
|
| 13 |
|
|
} elsif (/^## ([a-z0-9:_-]+)\t(.+)/) {
|
| 14 |
|
|
$i{$1} = $2;
|
| 15 |
|
|
}
|
| 16 |
|
|
}
|
| 17 |
|
|
|
| 18 |
|
|
@l = sort { $a->{ucs} <=> $b->{ucs} || $a->{fallback} <=> $b->{fallback} || $a->{local} <=> $b->{local} } @l;
|
| 19 |
|
|
|
| 20 |
|
|
print <<EOH;
|
| 21 |
|
|
#
|
| 22 |
|
|
<code_set_name> "@{[ $i{'ucm:code_set_name'} || $i{name} ]}"
|
| 23 |
|
|
@{[&{sub{
|
| 24 |
|
|
my $s = '';
|
| 25 |
|
|
for (sort split /\t/, $i{'ucm:code_set_alias'}) {
|
| 26 |
|
|
$s .= sprintf '<code_set_alias> "%s"%s', $_, "\n";
|
| 27 |
|
|
}
|
| 28 |
|
|
$s;
|
| 29 |
|
|
}}]}<mb_cur_min> @{[ $i{'ucm:mb_cur_min'} || 1 ]}
|
| 30 |
|
|
<mb_cur_max> @{[ $i{'ucm:mb_cur_max'} || 1 ]}
|
| 31 |
|
|
<subchar> @{[&{sub{
|
| 32 |
|
|
my $s = uc $i{'ucm:subchar'}|| $i{'<-ucs-substition'} || $i{substition} || '0x3F';
|
| 33 |
|
|
$s =~ s/^[0\\]X/\\x/;
|
| 34 |
|
|
$s =~ s/^\\x([0-9A-F][0-9A-F])([0-9A-F][0-9A-F])/\\x$1\\x$2/;
|
| 35 |
|
|
$s;
|
| 36 |
|
|
}}]}
|
| 37 |
|
|
#
|
| 38 |
|
|
CHARMAP
|
| 39 |
|
|
EOH
|
| 40 |
|
|
|
| 41 |
|
|
for (@l) {
|
| 42 |
|
|
printf q{<U%04X> \x%02X |%d # %s}, $_->{ucs}, $_->{local}, $_->{fallback}, $_->{comment}."\n";
|
| 43 |
|
|
}
|
| 44 |
|
|
|
| 45 |
|
|
print "END CHARMAP\n";
|