charset: intro and navigation of common presets
authorMischa POSLAWSKY <perl@shiar.org>
Sat, 8 Apr 2017 18:15:56 +0000 (20:15 +0200)
committerMischa POSLAWSKY <perl@shiar.org>
Mon, 24 Apr 2017 23:51:41 +0000 (01:51 +0200)
charset.plp

index 18d7c50453c83ca2237ee5c9773473123f338a7f..f26b7bdce3a7d495bb61d69c5d6e205735fcb573 100644 (file)
@@ -17,8 +17,53 @@ Html({
 
 my @tablist = split m{/+}, $Request || 'default';
 
+use List::Util qw( first pairmap pairfirst pairs );
+
 :>
-<h1>Character encoding</h1>
+<h1>Character encodings</h1>
+
+<p>
+<:
+if ($tablist[0] eq 'default') {
+       say "Overview of Unicode allocation and common latin code pages.";
+       say "Compare alternate charsets:";
+}
+else {
+       say "Charset comparison:";
+}
+
+sub optionlink {
+       my ($title, $href, $selected) = @_;
+       return sprintf(
+               $selected ? '<strong>%s</strong>' : '<a href="%2$s">%s</a>',
+               EscapeHTML($title), $href
+       );
+}
+
+print join " •\n", (
+       map {
+               join " ·\n", pairmap {
+                       optionlink($b || ucfirst $a, "/charset/$a?compare", $a eq $Request);
+               } @{$_}
+       }
+       [
+               iso      => 'ISO',
+               dos      => 'DOS',
+               mac      => 'Apple',
+               ebcdic   => 'EBCDIC',
+       ],
+       [
+               westeur  => 'West',
+               centeur  => 'Central',
+               norteur  => 'North European',
+               turkish  => 0,
+               greek    => 0,
+               cyrillic => 0,
+               hebrew   => 0,
+       ],
+);
+:>.
+</p>
 
 <:
 use POSIX qw( ceil );
@@ -46,6 +91,7 @@ sub tabinput {
                westeur    => [qw( iso-8859-1 iso-8859-15 cp1252 iso-8859-14 cp850 hp-roman8 nextstep MacRoman )],
                centeur    => [qw( iso-8859-2 iso-8859-16 cp1250 cp852 MacRomanian MacCroatian MacCentralEurRoman )], # MacRumanian only for DB
                turkish    => [qw( iso-8859-9 iso-8859-3 cp1254 cp857 MacTurkish )],
+               norteur    => [qw( baltic nordic )],
                baltic     => [qw( iso-8859-4 iso-8859-13 cp1257 cp775 )],
                nordic     => [qw( iso-8859-10 cp865 cp861 MacIcelandic MacSami )],
                cyrillic   => [qw( koi8-r koi8-u koi8-f iso-8859-5 cp1251 MacCyrillic cp866 cp855
@@ -82,8 +128,6 @@ sub tabinput {
        my $params = $input =~ s/[+](.*)\z// ? $1 : undef;
 
        if (not defined $params) {
-               use List::Util qw( first pairfirst pairs );
-
                state $INHERIT = {
                        'cp437'       => ['cp850' => 0, 'ascii' => '0-31+128'], # ascii range overridden later
                        'gsm0338'     => ['ascii' => '0-127'],