+ 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 1024;
+ $row{set} = 'Unicode planes';
+ $row{cell} = do 'charset-ucplanes.inc.pl'
+ or Alert('Table data could not be read', $@ || $!);
+ $row{cols} *= 2;
+ }
+ elsif ($row{set} = Encode::resolve_alias($input)) {
+ if ($row{set} eq 'Internal') {
+ $row{table} = ' ' x ($endpoint < 255 ? 640 : 8192);
+ $row{set} = 'Unicode BMP';
+ $row{cell} = do 'charset-unicode.inc.pl'
+ or Alert('Table data could not be read', $@ || $!);
+ }
+ elsif ($row{set} eq 'utf-8-strict') {
+ $row{table} = undef;
+ $row{set} = 'UTF-8';
+ $row{cell} = do 'charset-utf8.inc.pl'
+ or Alert('Table data could not be read', $@ || $!);
+ }
+ else {
+ $row{table} = Encode::decode($row{set}, pack 'C*', $row{offset} .. $endpoint);
+ # (~16x faster than decoding in loop;
+ # substr strings is twice as fast as splitting to an array)
+
+ if ($row{set} eq 'cp437') {
+ substr($row{table}, 237, 1) = pack 'U*', 0x3D5; # phi sign
+ substr($row{table}, 0, 32) = pack 'U*', map {hex} qw(
+ 2007 263A 263B 2665 2666 2663 2660 2022
+ 25D8 25CB 25D9 2642 2640 266A 266B 263C
+ 25BA 25C4 2195 203C 00B6 00A7 25AC 21A8
+ 2191 2193 2192 2190 221F 2194 25B2 25BC
+ );
+ }
+ }
+ }
+ else {
+ Alert("Encoding <q>$input</q> unknown");
+ return;
+ }
+ push @request, \%row;
+}
+tabinput($_) for @tablist;