--- perl/lib/Encode/Table.pm 2002/10/04 23:58:04 1.1 +++ perl/lib/Encode/Table.pm 2002/10/05 05:01:24 1.3 @@ -8,7 +8,7 @@ package Encode::Table; use strict; use vars qw(%TABLE $VERSION); -$VERSION = do {my @r =(q$Revision: 1.1 $ =~ /\d+/g);sprintf "%d."."%02d" x $#r, @r}; +$VERSION = do {my @r =(q$Revision: 1.3 $ =~ /\d+/g);sprintf "%d."."%02d" x $#r, @r}; ## Builtin tables for (0x00..0x7F) { @@ -16,12 +16,22 @@ $TABLE{ascii_to_ucs}->{$c} = $c; $TABLE{ucs_to_ascii}->{$c} = $c; } +$Encode::Table::ascii::VERSION = $VERSION; +for (0xA0..0xFF) { + my $c = chr $_; + $TABLE{isoiec8859_1_to_ucs}->{$c} = $c; + $TABLE{ucs_to_isoiec8859_1}->{$c} = $c; +} +$Encode::Table::isoiec8859_1::VERSION = $VERSION; my %_Cache; -sub convert ($@) { +sub convert ($@%) { + return $_[0] unless @{$_[1]} > 0; my @s = split //, shift; my $tbl = shift; my $tbls = join ' ', @$tbl; + my %option = @_; + load_table (@$tbl) if $option{-autoload}; for my $c (@s) { unless (defined $_Cache{$tbls}->{$c}) { for (@$tbl) { @@ -36,6 +46,18 @@ join '', @s; } +sub load_table (@) { + no strict 'refs'; + for (@_) { + my $name = $_; + if ($name =~ /^ucs_to_(.+)$/) { $name = $1 } + elsif ($name =~ /^(.+)_to_ucs$/) { $name = $1 } + unless (${ 'Encode::Table::' . $name . '::VERSION' }) { + eval qq{require Encode::Table::$name; Encode::Table::$name->import} or warn $@; + } + } +} + 1; __END__ @@ -52,5 +74,5 @@ =cut -# $Date: 2002/10/04 23:58:04 $ -### $Source: /app/local/cvsrepo/suikacvs/perl/lib/Encode/Table.pm,v $ ends here +# $Date: 2002/10/05 05:01:24 $ +### $RCSfile: Table.pm,v $ ends here