| 1 |
wakaba |
1.1 |
#!/usr/bin/perl |
| 2 |
|
|
use strict; |
| 3 |
|
|
use 5.7.3; |
| 4 |
|
|
|
| 5 |
|
|
require Encode; |
| 6 |
|
|
my %T; |
| 7 |
|
|
my %option; |
| 8 |
|
|
while (<>) { |
| 9 |
|
|
if (/^0x([0-9A-F][0-9A-F][0-9A-F][0-9A-F])\tU\+([0-9A-F]+)\t/) { |
| 10 |
|
|
$T{ hex $1 } = hex $2; |
| 11 |
|
|
} elsif (/^#\?o ([A-Za-z0-9-]+)="([^"]+)"/) { |
| 12 |
|
|
my $n = $1; $n =~ tr/-/_/; $option{$n} = $2; |
| 13 |
|
|
} |
| 14 |
|
|
} |
| 15 |
|
|
|
| 16 |
|
|
require 'internal.pl'; |
| 17 |
|
|
$option{offset} ||= &internal::cp_start (%option) || $internal::cp_start{ $option{charset_name} || $option{table_name} }; |
| 18 |
|
|
|
| 19 |
|
|
my (@T, @U); |
| 20 |
|
|
$option{_start} = $option{charset_chars} == 94 ? 0x21 : 0x20; |
| 21 |
|
|
@U = sort { $a->[0] <=> $b->[0] } |
| 22 |
|
|
map { |
| 23 |
|
|
[ (int ($_ / 0x100) - $option{_start}) * $option{charset_chars} |
| 24 |
|
|
+ (($_ % 0x100) - $option{_start}) + $option{offset}, |
| 25 |
|
|
$T{ $_ } ] |
| 26 |
|
|
} keys %T; |
| 27 |
|
|
|
| 28 |
|
|
my $tbl = ''; |
| 29 |
|
|
my $pack = ''; |
| 30 |
|
|
for (@U) { |
| 31 |
|
|
for ($_->[0], $_->[1]) { |
| 32 |
|
|
$_ = chr $_; $_ = $_ eq "\\" ? "\\\\" : $_ eq q(') ? q(\') : $_; |
| 33 |
|
|
Encode::_utf8_off ($_); |
| 34 |
|
|
$tbl .= $_; |
| 35 |
|
|
$pack .= 'a' . length ($_); |
| 36 |
|
|
} |
| 37 |
|
|
} |
| 38 |
|
|
|
| 39 |
|
|
print <<EOH; |
| 40 |
|
|
## This file is auto-generated (at @{[ sprintf '%04d-%02d-%02dT%02d:%02d:%02dZ', (gmtime)[5]+1900, (gmtime)[4]+1, (gmtime)[3,2,1,0] ]}). |
| 41 |
|
|
## Do not edit by hand! |
| 42 |
|
|
|
| 43 |
|
|
=head1 NAME |
| 44 |
|
|
|
| 45 |
|
|
Encode::Table::$option{table_name} --- Convertion tables |
| 46 |
|
|
used with Encode::Table, C<$option{table_name}_to_ucs> |
| 47 |
|
|
and C<ucs_to_$option{table_name}> |
| 48 |
|
|
|
| 49 |
|
|
=head1 TABLES |
| 50 |
|
|
|
| 51 |
|
|
=over 4 |
| 52 |
|
|
|
| 53 |
|
|
=item $option{table_name}_to_ucs |
| 54 |
|
|
|
| 55 |
|
|
Convertion table of $option{table_name} -> ucs |
| 56 |
|
|
|
| 57 |
|
|
=item ucs_to_$option{table_name} |
| 58 |
|
|
|
| 59 |
|
|
Convertion table of ucs -> $option{table_name} |
| 60 |
|
|
|
| 61 |
|
|
=back |
| 62 |
|
|
|
| 63 |
|
|
=head1 SEE ALSO |
| 64 |
|
|
|
| 65 |
|
|
Encode::Table |
| 66 |
|
|
|
| 67 |
|
|
=head1 LICENSE |
| 68 |
|
|
|
| 69 |
|
|
See source table of this module. (It may be named as |
| 70 |
|
|
C<$option{table_name}.tbr>.) |
| 71 |
|
|
|
| 72 |
|
|
=cut |
| 73 |
|
|
|
| 74 |
|
|
package Encode::Table::$option{table_name}; |
| 75 |
|
|
use strict; |
| 76 |
|
|
use vars qw/%L2U %U2L/; |
| 77 |
|
|
|
| 78 |
|
|
## These tables are embeded in binary, so that your editor |
| 79 |
|
|
## might break the data or might hang up. |
| 80 |
|
|
|
| 81 |
|
|
|
| 82 |
|
|
|
| 83 |
|
|
|
| 84 |
|
|
|
| 85 |
|
|
|
| 86 |
|
|
|
| 87 |
|
|
|
| 88 |
|
|
|
| 89 |
|
|
# |
| 90 |
|
|
|
| 91 |
|
|
%L2U = map {Encode::_utf8_on (\$_); \$_} unpack (q{$pack}, <<'END'); |
| 92 |
|
|
EOH |
| 93 |
|
|
|
| 94 |
|
|
print $tbl,"\nEND\n"; |
| 95 |
|
|
|
| 96 |
|
|
print <<EOH; |
| 97 |
|
|
%U2L = reverse %L2U; |
| 98 |
|
|
sub import { |
| 99 |
|
|
\$Encode::Table::TABLE{"$option{table_name}_to_ucs"} = \\%L2U; |
| 100 |
|
|
\$Encode::Table::TABLE{"ucs_to_$option{table_name}"} = \\%U2L; |
| 101 |
|
|
} |
| 102 |
|
|
1; |
| 103 |
|
|
### $option{table_name} ends here |
| 104 |
|
|
EOH |
| 105 |
|
|
|
| 106 |
|
|
1; ## $Date: 2002/08/28 09:45:59 $ |
| 107 |
|
|
### tbl2pm.pl ends here |