charset: unicode preset with all blocks and planes
authorMischa POSLAWSKY <perl@shiar.org>
Sat, 8 Apr 2017 20:40:50 +0000 (22:40 +0200)
committerMischa POSLAWSKY <perl@shiar.org>
Mon, 24 Apr 2017 23:51:41 +0000 (01:51 +0200)
Support unicode table offsets and width option to display all data.

charset.plp

index f26b7bdce3a7d495bb61d69c5d6e205735fcb573..54e3b45761017930cf0b466d7d0c3295d995e7f5 100644 (file)
@@ -61,6 +61,7 @@ print join " •\n", (
                cyrillic => 0,
                hebrew   => 0,
        ],
+       [ uc => 'Unicode' ],
 );
 :>.
 </p>
@@ -77,6 +78,7 @@ sub tabinput {
 
        state $ALIAS = {
                default    => [qw( unicode+0-639 utf-8 iso-8859-1 iso-8859-15 cp1252 cp437 cp850 )],
+               uc         => [qw( U++ unicode+0-4095 unicode+4096-6319  unicode+6320-8191 )],
                us         => [qw( cp437 cp863 gsm0338 AdobeStandardEncoding )],
                ebcdic     => [qw( cp37 cp500 cp1047 posix-bc cp1026 cp875 )],
                iso        => [map {"iso-8859-$_"} 1 .. 11, 13 .. 16],
@@ -219,7 +221,8 @@ sub tabinput {
                }
                $visible->{$_} //= 0 for $row{parent} || ();
        }
-       else {
+
+       if (length $params) {
                # manual option to double table width
                $row{cols} *= 2 if $params =~ s/[+]\z//;
        }
@@ -257,15 +260,21 @@ sub tabinput {
                $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{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};
+
+                       $row{endpoint  } = $row{cell}->{colsize} * ($endpoint || 8191);
+                       $row{startpoint} = $row{cell}->{colsize} * $row{offset};
+                       $row{offset} = 0;
+                       $row{set} = 'Unicode ' . (
+                               $row{startpoint} <  0x10000 && $row{endpoint} < 0x10000 ? 'BMP' :
+                               $row{startpoint} >= 0x10000 && $row{endpoint} < 0x20000 ? 'SMP' :
+                               'allocations'
+                       );
                }
                elsif ($row{set} eq 'utf-8-strict') {
                        $row{set} = 'UTF-8';
@@ -380,7 +389,7 @@ for my $row (@request) {
        my $coldigits = ceil(log($colsize * $cols) / log(16));  # uniform length of hexadecimal header
        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 $offset = $row->{startpoint} || 0;
 
        printf '<div class="section"><table class="glyphs%s">', !$row->{cell} && ' charmap';
        my $title = $row->{set};