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{set} = sprintf 'Unicode block U+%02Xxx', $start >> 8;
}
elsif ($input eq 'U') {
- $row{table} = ' ' x 1024;
+ $row{len} = 1024;
$row{set} = 'Unicode planes';
$row{cell} = do 'charset-ucplanes.inc.pl'
or Alert('Table data could not be read', $@ || $!);
}
elsif ($row{set} = Encode::resolve_alias($input)) {
if ($row{set} eq 'Internal') {
- $row{table} = ' ' x ($endpoint < 255 ? 640 : 8192);
+ $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', $@ || $!);
}
elsif ($row{set} eq 'utf-8-strict') {
- $row{table} = undef;
+ $row{len} = 256;
$row{set} = 'UTF-8';
$row{cell} = do 'charset-utf8.inc.pl'
or Alert('Table data could not be read', $@ || $!);
}
else {
+ $row{len} = $endpoint - $row{offset};
$row{table} = Encode::decode($row{set}, pack 'C*', $row{offset} .. $endpoint);
# (~16x faster than decoding in loop;
# substr strings is twice as fast as splitting to an array)
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 + (length($row->{table}) || 256) * $colsize;
+ my $endpoint = $offset + $row->{len} * $colsize;
printf '<div class="section"><table class="glyphs%s">', !$row->{cell} && ' charmap';
my $title = $row->{set};