charset: move inheritance metadata to include
authorMischa POSLAWSKY <perl@shiar.org>
Sat, 22 Apr 2017 09:42:35 +0000 (11:42 +0200)
committerMischa POSLAWSKY <perl@shiar.org>
Thu, 25 May 2017 20:10:24 +0000 (22:10 +0200)
charset-encoding.inc.pl [new file with mode: 0644]
charset.plp

diff --git a/charset-encoding.inc.pl b/charset-encoding.inc.pl
new file mode 100644 (file)
index 0000000..9ae8523
--- /dev/null
@@ -0,0 +1,83 @@
+use 5.014;
+use warnings;
+
++{
+       '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'],
+};
index 7e115a8..7ff3f42 100644 (file)
@@ -12,7 +12,10 @@ Html({
                reference common overview table
        '],
        stylesheet => [qw'light'],
-       data => [qw'charset-unicode.inc.pl charset-ucplanes.inc.pl charset-utf8.inc.pl'],
+       data => [qw(
+               charset-encoding.inc.pl
+               charset-unicode.inc.pl charset-ucplanes.inc.pl charset-utf8.inc.pl
+       )],
 });
 
 my @tablist = split m{/+}, $Request || 'default';
@@ -73,6 +76,9 @@ use Shiar_Sheet::FormatChar;
 my $glyphs = Shiar_Sheet::FormatChar->new;
 my @request;
 
+my $INHERIT = do 'charset-encoding.inc.pl'
+       or Alert('Encoding metadata could not be read', $@ || $!);
+
 sub tabinput {
        # generate character table(s)
        my $input = shift or return;
@@ -130,88 +136,6 @@ sub tabinput {
        my $params = $input =~ s/[+](.*)\z// ? $1 : undef;
 
        if (not defined $params) {
-               state $INHERIT = {
-                       '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'],
-
-               };
-
                my @parents = @{ $INHERIT->{$input} || [] };
 
                if (my ($parent, $part) = pairfirst { defined $visible->{$a} } @parents) {