| 2 |
use strict; |
use strict; |
| 3 |
use 5.7.3; |
use 5.7.3; |
| 4 |
|
|
| 5 |
|
=head1 NAME |
| 6 |
|
|
| 7 |
|
tbl2pm --- Perl module generator from (completed) PETBL |
| 8 |
|
table file |
| 9 |
|
|
| 10 |
|
=head1 DESCRIPTION |
| 11 |
|
|
| 12 |
|
This script generates dumped perl module file of convertion |
| 13 |
|
table used with Encode::Table module. |
| 14 |
|
|
| 15 |
|
=head1 USAGE |
| 16 |
|
|
| 17 |
|
$ ./tbl2pm.pl table.tbl > table.pm |
| 18 |
|
|
| 19 |
|
=cut |
| 20 |
|
|
| 21 |
require Encode; |
require Encode; |
| 22 |
my %T; |
my %T; |
| 23 |
my %option; |
my %option; |
| 89 |
|
|
| 90 |
package Encode::Table::$option{table_name}; |
package Encode::Table::$option{table_name}; |
| 91 |
use strict; |
use strict; |
| 92 |
use vars qw/%L2U %U2L/; |
use vars qw/%L2U %U2L \$VERSION/; |
| 93 |
|
\$VERSION = q(@{[sprintf '%04d.%02d%02d', (gmtime)[5]+1900, (gmtime)[4]+1, (gmtime)[3]]}); |
| 94 |
|
|
| 95 |
## These tables are embeded in binary, so that your editor |
## These tables are embeded in binary, so that your editor |
| 96 |
## might break the data or might hang up. |
## might break the data or might hang up. |
| 105 |
|
|
| 106 |
# |
# |
| 107 |
|
|
| 108 |
%L2U = map {Encode::_utf8_on (\$_); \$_} unpack (q{$pack}, <<'END'); |
%L2U = map {Encode::_utf8_on (\$_); \$_} unpack |
| 109 |
|
(q{$pack}, <<'END'); |
| 110 |
EOH |
EOH |
| 111 |
|
|
| 112 |
print $tbl,"\nEND\n"; |
print $tbl,"\nEND\n"; |
| 114 |
print <<EOH; |
print <<EOH; |
| 115 |
%U2L = reverse %L2U; |
%U2L = reverse %L2U; |
| 116 |
sub import { |
sub import { |
| 117 |
\$Encode::Table::TABLE{"$option{table_name}_to_ucs"} = \\%L2U; |
\$Encode::Table::TABLE{$option{table_name}_to_ucs} = \\%L2U; |
| 118 |
\$Encode::Table::TABLE{"ucs_to_$option{table_name}"} = \\%U2L; |
\$Encode::Table::TABLE{ucs_to_$option{table_name}} = \\%U2L; |
| 119 |
} |
} |
| 120 |
1; |
1; |
| 121 |
### $option{table_name} ends here |
### $option{table_name}.pm ends here |
| 122 |
EOH |
EOH |
| 123 |
|
|
| 124 |
|
|
| 125 |
|
=head1 SEE ALSO |
| 126 |
|
|
| 127 |
|
Encode::Table, internal.pl |
| 128 |
|
|
| 129 |
|
=head1 AUTHOR |
| 130 |
|
|
| 131 |
|
Nanashi-san |
| 132 |
|
|
| 133 |
|
=head1 LICENSE |
| 134 |
|
|
| 135 |
|
Copyright 2002 AUTHOR |
| 136 |
|
|
| 137 |
|
This library is free software; you can redistribute it |
| 138 |
|
and/or modify it under the same terms as Perl itself. |
| 139 |
|
|
| 140 |
|
AUTHOR does NOT claim any right to the data generated by |
| 141 |
|
this script. License of generated data fully depends |
| 142 |
|
author of source data. |
| 143 |
|
|
| 144 |
|
=cut |
| 145 |
|
|
| 146 |
1; ## $Date$ |
1; ## $Date$ |
| 147 |
### tbl2pm.pl ends here |
### tbl2pm.pl ends here |