1 |
|
2 |
=head1 NAME |
3 |
|
4 |
Encode::Table --- Inter-coding-space table convertion |
5 |
|
6 |
=cut |
7 |
|
8 |
package Encode::Table; |
9 |
use strict; |
10 |
use vars qw(%TABLE $VERSION); |
11 |
$VERSION = do {my @r =(q$Revision: 1.2 $ =~ /\d+/g);sprintf "%d."."%02d" x $#r, @r}; |
12 |
|
13 |
## Builtin tables |
14 |
for (0x00..0x7F) { |
15 |
my $c = chr $_; |
16 |
$TABLE{ascii_to_ucs}->{$c} = $c; |
17 |
$TABLE{ucs_to_ascii}->{$c} = $c; |
18 |
} |
19 |
|
20 |
my %_Cache; |
21 |
sub convert ($@) { |
22 |
my @s = split //, shift; |
23 |
my $tbl = shift; |
24 |
my $tbls = join ' ', @$tbl; |
25 |
for my $c (@s) { |
26 |
unless (defined $_Cache{$tbls}->{$c}) { |
27 |
for (@$tbl) { |
28 |
if (defined $TABLE{$_}->{$c}) { |
29 |
$_Cache{$tbls}->{$c} = $TABLE{$_}->{$c}; last; |
30 |
} |
31 |
} |
32 |
$_Cache{$tbls}->{$c} = $c unless defined $_Cache{$tbls}->{$c}; ## Not found |
33 |
} |
34 |
$c = $_Cache{$tbls}->{$c}; |
35 |
} |
36 |
join '', @s; |
37 |
} |
38 |
|
39 |
1; |
40 |
__END__ |
41 |
|
42 |
=head1 AUTHORS |
43 |
|
44 |
Nanashi-san |
45 |
|
46 |
=head1 LICENSE |
47 |
|
48 |
Copyright 2002 AUTHORS |
49 |
|
50 |
This library is free software; you can redistribute it |
51 |
and/or modify it under the same terms as Perl itself. |
52 |
|
53 |
=cut |
54 |
|
55 |
# $Date: 2002/09/22 11:09:38 $ |
56 |
### $Source: $ ends here |