- print '<tbody>';
- for my $msb (0 .. $#nibble) {
- print '<tr><th>', $nibble[$msb];
- for my $lsb (0 .. $#nibble) {
- my $glyph = substr $tables[$tablenum], ($msb<<4) + $lsb, 1;
- if ($glyph eq $NOCHAR) {
- print '<td>';
- next;
+
+ if (defined $params and $params =~ m/^ (\d+) (-\d+)? /x) {
+ $row{offset} = $1;
+ $endpoint = -$2 if $2;
+ }
+
+ 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{len} = length $row{table};
+ $row{set} = sprintf 'Unicode block U+%02Xxx', $start >> 8;
+ }
+ elsif ($input eq 'U') {
+ $row{len} = 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{len} = $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{len} = 256;
+ $row{set} = 'UTF-8';
+ $row{cell} = do 'charset-utf8.inc.pl'
+ or Alert('Table data could not be read', $@ || $!);
+ }
+ else {
+ if ($row{set} eq 'MacHebrew') {
+ # array of possibly multiple characters per code point
+ $row{table} = [
+ map { Encode::decode($row{set}, pack 'C*', $_) } $row{offset} .. $endpoint
+ ];