X-Git-Url: http://git.shiar.nl/sheet.git/blobdiff_plain/a7ed385782fbc29016e768774dc3fbf6e6442885..1436e579bd7ccf52d5e53d2db969eb74093df149:/charset.plp diff --git a/charset.plp b/charset.plp index 4c673bc..51c391c 100644 --- a/charset.plp +++ b/charset.plp @@ -15,7 +15,7 @@ Html({ data => [qw'charset-unicode.inc.pl charset-utf8.inc.pl'], }); -my @tablist = split /[^\w-]+/, $Request || 'default'; +my @tablist = split m{/+}, $Request || 'default'; :>
$paramsis not in format start(-stop)(+restart(-end))", + ]); + + $row{offset} = $+{offset}; + $endpoint = $+{endpoint} if $+{endpoint}; + if (my $restart = $+{restart}) { + my $skip = int(($+{stop} || $row{offset}) / $row{cols}); + for ($skip + 1 .. ($restart / $row{cols}) - 1) { + $row{skip}->{ $_ * $row{cols} - $row{offset} }++; + } + } } if ($input =~ /^U([0-9a-f]+)(?:-([0-9a-f]+))?/) { @@ -69,34 +190,44 @@ sub tabinput { my $end = $2 ? hex($2) << 4 : $start + 240; $row{table} = join '', map { chr } $start .. $end+15; utf8::upgrade($row{table}); # prevent latin1 output + $row{endpoint} = $end + 14 - $start; $row{set} = sprintf 'Unicode block U+%02Xxx', $start >> 8; } elsif ($input eq 'U') { - $row{table} = ' ' x 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{table} = ' ' x ($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{table} = undef; $row{set} = 'UTF-8'; $row{cell} = do 'charset-utf8.inc.pl' or Alert('Table data could not be read', $@ || $!); + $row{endpoint} = 255; } else { - $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) + if ($row{set} eq 'MacHebrew' or $row{set} eq 'MacThai') { + # array of possibly multiple characters per code point + $row{table} = [ + map { Encode::decode($row{set}, pack 'C*', $_) } $row{offset} .. $endpoint + ]; + } + else { + # ~16x faster than decoding in loop; + # substr strings is twice as fast as splitting to an array + $row{table} = Encode::decode($row{set}, pack 'C*', $row{offset} .. $endpoint); + } + $row{endpoint} = $endpoint - $row{offset}; - if ($row{set} eq 'cp437') { + if ($row{set} eq 'cp437' and !$row{offset}) { substr($row{table}, 237, 1) = pack 'U*', 0x3D5; # phi sign substr($row{table}, 0, 32) = pack 'U*', map {hex} qw( 2007 263A 263B 2665 2666 2663 2660 2022 @@ -105,15 +236,18 @@ sub tabinput { 2191 2193 2192 2190 221F 2194 25B2 25BC ); } + + $visible->{ascii} = # assume common base + $visible->{ $row{set} } = 1; } } else { Alert("Encoding
$inputunknown"); return; } - return \%row; + push @request, \%row; } -my @request = map { tabinput($_) } @tablist; +tabinput($_) for @tablist; my $NOCHAR = chr 0xFFFD; @@ -176,11 +310,11 @@ for my $row (@request) { 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; printf '
'; { if (my $rowmod = $offset % $rowdiv) { @@ -207,12 +346,27 @@ for my $row (@request) { next; } - my $glyph = substr $row->{table}, $offset, 1; + my $glyph = ref $row->{table} eq 'ARRAY' ? $row->{table}->[$offset] : + substr $row->{table}, $offset, 1; if ($glyph eq $NOCHAR) { print ' | '; next; } + if (exists $get{compare}) { + state $visible = {}; + my $cp = $offset + $row->{offset}; + printf ' | %2$s',
+ $cp == ord $glyph ? 'l4' :
+ $row->{parent} && $glyph eq
+ Encode::decode($row->{parent}, pack 'C', $cp) ? 'l3' :
+ $visible->{$glyph} ? 'l2' :
+ 'l1',
+ $glyphs->glyph_html($glyph);
+ $visible->{$glyph}++;
+ next;
+ }
+
print "\n".$glyphs->glyph_cell($glyph);
}
continue {
@@ -227,7 +381,13 @@ for my $row (@request) {
-
|
---|