charset: show unicode blocks requested by U$num
[sheet.git] / charset.plp
index 41af494365bdfb096ccde286d68a236228872a8c..91de26bd81c002e5cff1e7fd896c76996c25c479 100644 (file)
@@ -53,7 +53,15 @@ 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 ($row{set} = resolve_alias($input)) {
                        if ($row{set} eq 'Internal') {
                                $row{table} = ' ' x ($endpoint < 255 ? 640 : 4096);
                                $row{set} = 'Unicode BMP';