my $input = shift or return;
state $ALIAS = {
- default => [qw( unicode+0-192 utf-8 iso-8859-1 iso-8859-15 cp1252 cp437 cp850 )],
+ default => [qw( unicode+0-639 utf-8 iso-8859-1 iso-8859-15 cp1252 cp437 cp850 )],
us => [qw( cp437 cp863 AdobeStandardEncoding gsm0338 )],
ebcdic => [qw( cp37 cp500 cp875 cp1026 cp1047 posix-bc )],
iso => [map {"iso-8859-$_"} 1 .. 11, 13 .. 16],
my $end = $2 ? hex($2) << 4 : $start + 240;
$row{table} = join '', map { chr } $start .. $end+15;
utf8::upgrade($row{table}); # prevent latin1 output
- $row{len} = length $row{table};
+ $row{endpoint} = $end + 14 - $start;
$row{set} = sprintf 'Unicode block U+%02Xxx', $start >> 8;
}
elsif ($input eq 'U') {
- $row{len} = 1024;
$row{set} = 'Unicode planes';
$row{cell} = do 'charset-ucplanes.inc.pl'
or Alert('Table data could not be read', $@ || $!);
$row{cols} *= 2;
+ $row{endpoint} = 1023 * $row{cell}->{colsize};
}
elsif ($row{set} = Encode::resolve_alias($input)) {
if ($row{set} eq 'Internal') {
- $row{len} = $endpoint < 255 ? 640 : 8192;
$row{set} = 'Unicode BMP';
$row{cell} = do 'charset-unicode.inc.pl'
or Alert('Table data could not be read', $@ || $!);
+ $row{endpoint} = ($endpoint || 8191) * $row{cell}->{colsize};
}
elsif ($row{set} eq 'utf-8-strict') {
- $row{len} = 256;
$row{set} = 'UTF-8';
$row{cell} = do 'charset-utf8.inc.pl'
or Alert('Table data could not be read', $@ || $!);
+ $row{endpoint} = 255;
}
else {
if ($row{set} eq 'MacHebrew') {
# substr strings is twice as fast as splitting to an array
$row{table} = Encode::decode($row{set}, pack 'C*', $row{offset} .. $endpoint);
}
- $row{len} = $endpoint - $row{offset};
+ $row{endpoint} = $endpoint - $row{offset};
if ($row{set} eq 'cp437' and !$row{offset}) {
substr($row{table}, 237, 1) = pack 'U*', 0x3D5; # phi sign
my $rowdiv = 16 ** $coldigits; # row divide for column digits
$rowdiv = 1 if $rowdiv != $cols * $colsize; # divide only if all columns are matched
my $offset = 0;
- my $endpoint = $offset + $row->{len} * $colsize;
printf '<div class="section"><table class="glyphs%s">', !$row->{cell} && ' charmap';
my $title = $row->{set};
print "\n";
}
print '<tbody>';
- while ($offset < $endpoint - 1) {
+ while ($offset < $row->{endpoint}) {
print '<tr><th>';
{
if (my $rowmod = $offset % $rowdiv) {