charset: unicode plane overview (macro blocks)
[sheet.git] / charset.plp
index 41af494365bdfb096ccde286d68a236228872a8c..6b6e7d0bf7655e36d7887b8b51433c9d30b20c91 100644 (file)
@@ -53,7 +53,20 @@ my @request = map {
                if ($input =~ s/-$//) {
                        $endpoint = $row{offset} ? $row{offset} < 160 ? 159 : 191 : 127;
                }
-               if ($row{set} = resolve_alias($input)) {
+
+               if ($input =~ /^U([0-9a-f]+)(?:-([0-9a-f]+))?/) {
+                       my $start = hex($1) << ($2 ? 4 : 8);
+                       my $end = $2 ? hex($2) << 4 : $start + 240;
+                       $row{table} = join '', map { chr } $start .. $end+15;
+                       utf8::upgrade($row{table});  # prevent latin1 output
+                       $row{set} = sprintf 'Unicode block U+%02Xxx', $start >> 8;
+               }
+               elsif ($input eq 'U') {
+                       $row{table} = ' ' x 512;
+                       $row{set} = 'Unicode planes';
+                       $row{cell} = do 'charset-ucplanes.inc.pl';
+               }
+               elsif ($row{set} = resolve_alias($input)) {
                        if ($row{set} eq 'Internal') {
                                $row{table} = ' ' x ($endpoint < 255 ? 640 : 4096);
                                $row{set} = 'Unicode BMP';
@@ -100,7 +113,7 @@ print "<ul>\n";
 
 my @nibble = (0..9, 'A'..'F');
 for my $row (@request) {
-       print '<li><table class="glyphs">';
+       printf '<li><table class="glyphs%s">', !$row->{cell} && ' charmap';
        printf '<caption>%s</caption>', $row->{set};
        print '<col>';
        for my $section (qw{thead}) {