charset: hexadecimal subselect options
authorMischa POSLAWSKY <perl@shiar.org>
Fri, 21 Apr 2017 21:11:35 +0000 (23:11 +0200)
committerMischa POSLAWSKY <perl@shiar.org>
Thu, 25 May 2017 20:10:24 +0000 (22:10 +0200)
Tables are all organised by rows of 16, making decimal representations
indirect and error-prone.

$INHERIT options converted using:
perl -pE 's/(?:'\''|\G[+-])\K(\d+)/sprintf "\%02X", $1/ge'

charset.plp

index 6d60e27..e725c11 100644 (file)
@@ -78,8 +78,8 @@ sub tabinput {
        my $input = shift or return;
 
        state $ALIAS = {
-               default    => [qw( u+0-639 utf-8+realsize iso-8859-1 iso-8859-15 cp1252 cp437 cp850 )],
-               unicode    => [qw( uu+cols=32+realsize u+0-4095 u+4096-6319 u+6320-8191 )],
+               default    => [qw( u+0-27F utf-8+realsize iso-8859-1 iso-8859-15 cp1252 cp437 cp850 )],
+               unicode    => [qw( uu+cols=32+realsize u+0-FFF u+1000-18AF u+18B0-1FFF )],
                us         => [qw( cp437 cp863 gsm0338 AdobeStandardEncoding )],
                ebcdic     => [qw( cp37 cp500 cp1047 posix-bc cp1026 cp875 )],
                iso        => [map {"iso-8859-$_"} 1 .. 11, 13 .. 16],
@@ -100,7 +100,7 @@ sub tabinput {
                cyrillic   => [qw( koi8-r koi8-u koi8-f iso-8859-5 cp1251 MacCyrillic cp866 cp855
                                   U4 U2DE-2DF UA64-A69 U50-52 )], # MacUkrainian is broken
                arabic     => [qw( iso-8859-6 cp1256 MacArabic cp864 cp1006 MacFarsi
-                                  U6 U8A-8F+0-31+64 U75-77 )],
+                                  U6 U8A-8F+0-1F+40 U75-77 )],
                greek      => [qw( iso-8859-7 cp1253 MacGreek cp737 cp869  U37-3F U1F )],
                hebrew     => [qw( iso-8859-8 cp1255 MacHebrew cp862  U59-5F )],
                thai       => [qw( iso-8859-11 cp874 MacThai )],
@@ -131,84 +131,84 @@ sub tabinput {
 
        if (not defined $params) {
                state $INHERIT = {
-                       'ascii'       => ['' => '0-127'],
-                       'cp437'       => ['cp850' => 0, 'ascii' => '0-31+128'], # ascii range overridden later
-                       'gsm0338'     => ['ascii' => '0-127'],
-                       'dingbats'    => ['' => '32-127+160'],
-                       'MacDingbats' => ['dingbats' => '128-159'],
-                       'AdobeZdingbat'=> ['MacDingbats' => '128-159'], # should be identical but maps to private use
-                       'symbol'      => ['' => '32-127+160'],
-                       'AdobeSymbol' => ['symbol' => '32-127+160', '' => '32-127+160'], # minor differences, irrelevant except for different '€'
-                       'wingdings'   => ['' => '32'],
-                       'wingdings2'  => ['' => '32'],
-                       'wingdings3'  => ['' => '32'],
-                       'webdings'    => ['' => '32'],
-
-                       'iso-8859-2'  => ['iso-8859-1' => '160'],
-                       'iso-8859-3'  => ['iso-8859-1' => '160'], #TODO: also apply to iso-8859-9
-                       'iso-8859-4'  => ['iso-8859-2' => '160'],
-                       'iso-8859-5'  => ['iso-8859-1' => '160'],
-                       'iso-8859-6'  => ['cp1256' => '128', 'iso-8859-1' => '160'],
-                       'iso-8859-7'  => ['iso-8859-1' => '160'],
-                       'iso-8859-8'  => ['iso-8859-1' => '160'],
-                       'iso-8859-9'  => ['iso-8859-1' => '208-223+240'],
-                       'iso-8859-10' => ['iso-8859-4' => '160'],
-                       'iso-8859-11' => ['iso-8859-1' => '160'],
-                       'iso-8859-13' => ['iso-8859-4' => '160'],
-                       'iso-8859-14' => ['iso-8859-1' => '160'],
-                       'iso-8859-15' => ['iso-8859-1' => '160-191'],
-                       'iso-8859-16' => ['iso-8859-2' => '160'],
-                       'hp-roman8'   => ['iso-8859-1' => '160'],
-
-                       'cp1252'      => ['iso-8859-1' => '128-159'],
-                       'cp1250'      => ['iso-8859-2' => '128-191', 'cp1252' => '128'],
-                       'cp1254'      => ['iso-8859-9' => '128-159', 'cp1252' => '128-159+208'],
-                       'cp874'       => ['iso-8859-11' => '128-159', 'cp1252' => '128'], # windows-874 actually cp1162
-                       'cp1257'      => ['iso-8859-13' => '128-159+255', 'cp1252' => '128'],
-                       'cp1251'      => ['cp1252' => '128'],
-                       'cp1253'      => ['cp1252' => '128'],
-                       'cp1255'      => ['iso-8859-8' => '128-223', 'cp1252' => '128'],
-                       'cp1256'      => ['cp1252' => '128'],
-                       'cp1258'      => ['cp1252' => '128-159+192'],
-
-                       'cp850'       => ['cp437' => '144'],
-                       'cp860'       => ['cp437' => '128-175'],
-                       'cp861'       => ['cp865' => '128-175'],
-                       'cp863'       => ['cp437' => '128-175'],
-                       'cp865'       => ['cp437' => '144-175'],
-                       'cp852'       => ['cp850' => '128', 'cp437' => '128'],
-                       'cp857'       => ['cp850' => '128-175+208-239', 'cp437' => '128'],
-                       'cp775'       => ['cp850' => '128'],  # partial cp437
-                       'cp866'       => ['cp437' => '128-175+224'],
-                       'cp855'       => ['cp437' => '128'],
-                       'cp1006'      => ['iso-8859-6' => '160', 'cp437' => '128'],
-                       'cp737'       => ['cp437' => '128-175+224'],
-                       'cp869'       => ['cp437' => '128'],
-                       'cp862'       => ['cp437' => '128-159'],
-                       'cp864'       => ['MacArabic' => '128', 'iso-8859-6' => '128', 'cp437' => '128'], #TODO: compare form variants
-
-                       'koi8-u'      => ['koi8-r' => '144-191'],
-                       'koi8-f'      => ['koi8-u' => '144-191'],
-
-                       'MacRomanian' => ['MacRoman' => '160-191+208-223'],
-                       'MacRumanian' => ['MacRomanian' => '160-191+208-223', 'MacRoman' => '160-191+208-223'],
-                       'MacCroatian' => ['MacRoman' => '160'],
-                       'MacCentralEurRoman' => ['MacRoman' => '128'],
-                       'MacIcelandic'=> ['MacRoman' => '160-175+208-239'],
-                       'MacTurkish'  => ['MacRoman' => '208-223'], # F5 is unassigned
-                       'MacSami'     => ['MacIcelandic' => '144-191+208-223+240', 'MacRoman' => '144'],
-                       'MacGreek'    => ['MacRoman' => '128'],
-                       'MacCyrillic' => ['MacRoman' => '128'],
-                       'MacHebrew'   => ['iso-8859-8' => '128', 'MacRoman' => '128-143+160'], # partial ascii
-                       'MacArabic'   => ['iso-8859-6' => '128', 'cp864' => '128', 'MacRoman' => '128'], #TODO: multiple parents
-                       'MacFarsi'    => ['MacArabic' => '176-191', 'MacRoman' => '128'],
-
-                       'cp37'        => ['posix-bc' => '0'],
-                       'posix-bc'    => ['cp1047' => '64'],
-                       'cp500'       => ['cp37' => '64-95+176-191'],
-                       'cp1047'      => ['cp37' => '16-47+80-95+160-191'],
-                       'cp1026'      => ['cp37' => '64'],
-                       'cp875'       => ['cp37' => '48'],
+                       'ascii'       => ['' => '00-7F'],
+                       'cp437'       => ['cp850' => 0, 'ascii' => '00-1F+80'], # ascii range overridden later
+                       'gsm0338'     => ['ascii' => '00-7F'],
+                       'dingbats'    => ['' => '20-7F+A0'],
+                       'MacDingbats' => ['dingbats' => '80-9F'],
+                       'AdobeZdingbat'=> ['MacDingbats' => '80-9F'], # should be identical but maps to private use
+                       'symbol'      => ['' => '20-7F+A0'],
+                       'AdobeSymbol' => ['symbol' => '20-7F+A0', '' => '20-7F+A0'], # minor differences, irrelevant except for different '€'
+                       'wingdings'   => ['' => '20'],
+                       'wingdings2'  => ['' => '20'],
+                       'wingdings3'  => ['' => '20'],
+                       'webdings'    => ['' => '20'],
+
+                       'iso-8859-2'  => ['iso-8859-1' => 'A0'],
+                       'iso-8859-3'  => ['iso-8859-1' => 'A0'], #TODO: also apply to iso-8859-9
+                       'iso-8859-4'  => ['iso-8859-2' => 'A0'],
+                       'iso-8859-5'  => ['iso-8859-1' => 'A0'],
+                       'iso-8859-6'  => ['cp1256' => '80', 'iso-8859-1' => 'A0'],
+                       'iso-8859-7'  => ['iso-8859-1' => 'A0'],
+                       'iso-8859-8'  => ['iso-8859-1' => 'A0'],
+                       'iso-8859-9'  => ['iso-8859-1' => 'D0-DF+F0'],
+                       'iso-8859-10' => ['iso-8859-4' => 'A0'],
+                       'iso-8859-11' => ['iso-8859-1' => 'A0'],
+                       'iso-8859-13' => ['iso-8859-4' => 'A0'],
+                       'iso-8859-14' => ['iso-8859-1' => 'A0'],
+                       'iso-8859-15' => ['iso-8859-1' => 'A0-BF'],
+                       'iso-8859-16' => ['iso-8859-2' => 'A0'],
+                       'hp-roman8'   => ['iso-8859-1' => 'A0'],
+
+                       'cp1252'      => ['iso-8859-1' => '80-9F'],
+                       'cp1250'      => ['iso-8859-2' => '80-BF', 'cp1252' => '80'],
+                       'cp1254'      => ['iso-8859-9' => '80-9F', 'cp1252' => '80-9F+D0'],
+                       'cp874'       => ['iso-8859-11' => '80-9F', 'cp1252' => '80'], # windows-874 actually cp1162
+                       'cp1257'      => ['iso-8859-13' => '80-9F+FF', 'cp1252' => '80'],
+                       'cp1251'      => ['cp1252' => '80'],
+                       'cp1253'      => ['cp1252' => '80'],
+                       'cp1255'      => ['iso-8859-8' => '80-DF', 'cp1252' => '80'],
+                       'cp1256'      => ['cp1252' => '80'],
+                       'cp1258'      => ['cp1252' => '80-9F+C0'],
+
+                       'cp850'       => ['cp437' => '90'],
+                       'cp860'       => ['cp437' => '80-AF'],
+                       'cp861'       => ['cp865' => '80-AF'],
+                       'cp863'       => ['cp437' => '80-AF'],
+                       'cp865'       => ['cp437' => '90-AF'],
+                       'cp852'       => ['cp850' => '80', 'cp437' => '80'],
+                       'cp857'       => ['cp850' => '80-AF+D0-EF', 'cp437' => '80'],
+                       'cp775'       => ['cp850' => '80'],  # partial cp437
+                       'cp866'       => ['cp437' => '80-AF+E0'],
+                       'cp855'       => ['cp437' => '80'],
+                       'cp1006'      => ['iso-8859-6' => 'A0', 'cp437' => '80'],
+                       'cp737'       => ['cp437' => '80-AF+E0'],
+                       'cp869'       => ['cp437' => '80'],
+                       'cp862'       => ['cp437' => '80-9F'],
+                       'cp864'       => ['MacArabic' => '80', 'iso-8859-6' => '80', 'cp437' => '80'], #TODO: compare form variants
+
+                       'koi8-u'      => ['koi8-r' => '90-BF'],
+                       'koi8-f'      => ['koi8-u' => '90-BF'],
+
+                       'MacRomanian' => ['MacRoman' => 'A0-BF+D0-DF'],
+                       'MacRumanian' => ['MacRomanian' => 'A0-BF+D0-DF', 'MacRoman' => 'A0-BF+D0-DF'],
+                       'MacCroatian' => ['MacRoman' => 'A0'],
+                       'MacCentralEurRoman' => ['MacRoman' => '80'],
+                       'MacIcelandic'=> ['MacRoman' => 'A0-AF+D0-EF'],
+                       'MacTurkish'  => ['MacRoman' => 'D0-DF'], # F5 is unassigned
+                       'MacSami'     => ['MacIcelandic' => '90-BF+D0-DF+F0', 'MacRoman' => '90'],
+                       'MacGreek'    => ['MacRoman' => '80'],
+                       'MacCyrillic' => ['MacRoman' => '80'],
+                       'MacHebrew'   => ['iso-8859-8' => '80', 'MacRoman' => '80-8F+A0'], # partial ascii
+                       'MacArabic'   => ['iso-8859-6' => '80', 'cp864' => '80', 'MacRoman' => '80'], #TODO: multiple parents
+                       'MacFarsi'    => ['MacArabic' => 'B0-BF', 'MacRoman' => '80'],
+
+                       'cp37'        => ['posix-bc' => '00'],
+                       'posix-bc'    => ['cp1047' => '40'],
+                       'cp500'       => ['cp37' => '40-5F+B0-BF'],
+                       'cp1047'      => ['cp37' => '10-2F+50-5F+A0-BF'],
+                       'cp1026'      => ['cp37' => '40'],
+                       'cp875'       => ['cp37' => '30'],
 
                };
 
@@ -217,17 +217,17 @@ sub tabinput {
                if (my ($parent, $part) = pairfirst { defined $visible->{$a} } @parents) {
                        $row{parent} = $parent;
                        $params = $part;
-                       $params = 128 unless $visible->{$parent}
+                       $params = 80 unless $visible->{$parent}
                                or ($input eq 'MacCroatian' and defined $visible->{MacRomanian});
                }
                elsif (defined $visible->{ascii}) {
                        $row{parent} = $parents[0];
-                       $params = $parents[1] // 128;
-                       $params = 128 if $params >= 128;  # ascii offset at most
+                       $params = $parents[1] // 80;
+                       $params = 80 if hex $params >= 128;  # ascii offset at most
                }
                elsif (@parents) {
                        $row{parent} = $parents[0];
-                       $params = $parents[1] if $parents[1] == 0;  # apply ascii end
+                       $params = $parents[1] if hex $parents[1] == 0;  # apply ascii end
                }
                $visible->{$_} //= 0 for $row{parent} || ();
        }
@@ -239,18 +239,18 @@ sub tabinput {
                elsif ($param =~ m{ \A cols = (\d+) \z }x) {
                        $row{cols} = $1;
                }
-               elsif ($param =~ m{ \A (?<start> \d+) (?: [-] (?<end> \d+) )? \z }x) {
+               elsif ($param =~ m{ \A (?<start> \p{AHex}+) (?: [-] (?<end> \p{AHex}+) )? \z }x) {
                        if (defined $row{endpoint}) {
                                # extend earlier range
                                my $skip = int(($row{endpoint} || $row{startpoint}) / $row{cols});
-                               for ($skip + 1 .. ($+{start} / $row{cols}) - 1) {
+                               for ($skip + 1 .. (hex($+{start}) / $row{cols}) - 1) {
                                        $row{skip}->{ $_ * $row{cols} - $row{startpoint} }++;
                                }
                        }
                        else {
-                               $row{startpoint} = $+{start};
+                               $row{startpoint} = hex $+{start};
                        }
-                       $row{endpoint} = $+{end} || 0;
+                       $row{endpoint} = hex($+{end} || 0);
                }
                else {
                        Alert("Unknown option <q>$param</q> for charset $input");
@@ -436,8 +436,9 @@ for my $row (@request) {
                printf '<th>%0*X', $coldigits, $_ * $colsize for 0 .. $cols - 1;
                print "\n";
        }
+
        print '<tbody>';
-       while ($offset < $row->{endpoint} * $colsize) {
+       while ($offset <= $row->{endpoint} * $colsize) {
                if ($row->{skip}->{$offset}) {
                        $offset += $cols * $colsize;
                        next;