1 package Encode::Tcl::Table;
3 our $VERSION = do {my @r=(q$Revision: 1.1 $ =~ /\d+/g); sprintf "%d."."%02d" x $#r, @r};
4 use base 'Encode::Encoding';
11 my ($obj,$fh,$name,$type) = @_;
13 my ($def,$sym,$pages) = split(/\s+/,scalar(<$fh>));
22 my $page = hex($line);
24 $leading[$page] = 1 if $page;
26 for (my $i = 0; $i < 16; $i++)
29 for (my $j = 0; $j < 16; $j++)
31 my $val = hex(substr($line,0,4,''));
34 my $uch = pack('U', $val); # chr($val);
46 $touni[$page] = \@page;
49 ? $obj->can("rep_$type")
52 ($_[0] > 255) || $leading[$_[0]] ? 'n' : 'C';
55 $obj->{'ToUni'} = \@touni;
56 $obj->{'FmUni'} = \%fmuni;
58 $obj->{'Num'} = $count;
66 #sub rep_M { ($_[0] > 255) ? 'n' : 'C' }
71 $ch = 0 unless @_ > 1;
77 my($obj,$str,$chk) = @_;
78 my $name = $obj->{'Name'};
79 my $rep = $obj->{'Rep'};
80 my $touni = $obj->{'ToUni'};
84 my $cc = substr($str,0,1,'');
87 if (&$rep($ch) eq 'C')
89 $x = $touni->[0][$ch];
95 $str = pack('C',$ch); # split leading byte
98 my $c2 = substr($str,0,1,'');
100 $x = $touni->[$ch][ord($c2)];
104 Encode::Tcl::no_map_in_decode($name, $cc.$str);
108 $_[1] = $str if $chk;
115 my ($obj,$uni,$chk) = @_;
116 my $fmuni = $obj->{'FmUni'};
117 my $def = $obj->{'Def'};
118 my $name = $obj->{'Name'};
119 my $rep = $obj->{'Rep'};
123 my $ch = substr($uni,0,1,'');
124 my $x = $fmuni->{$ch};
129 Encode::Tcl::no_map_in_encode(ord($ch), $name)
133 $str .= pack(&$rep($x),$x);
135 $_[1] = $uni if $chk;