', $nibble[$msb];
- for my $lsb (0 .. $#nibble) {
- my $glyph = substr $tables[$tablenum], ($msb<<4) + $lsb, 1;
- if ($glyph eq $NOCHAR) {
- print ' | ';
- next;
- }
- my $info = [ord $glyph];
- if (defined (my $mnem = $di{ord $glyph})) {
- $info = $diinfo->{$mnem};
+ if ($row{offset}) {
+ $row{setnote} = 'over cp437' if $input eq 'cp850';
+ $row{setnote} = 'over iso-8859-1' if $input =~ /^iso-8859-|^cp125/;
+ }
+
+ 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
+ );
}
- my ($codepoint, $name, $prop, $script, $string) = @$info;
+ }
+ }
+ else {
+ Alert("Encoding $input unknown");
+ return;
+ }
+ return \%row;
+}
+my @request = map { tabinput($_) } @tablist;
+
+my $NOCHAR = chr 0xFFFD;
- $glyph = quote($string || $glyph);
- my $desc = sprintf 'U+%04X%s', $codepoint, $name && " ($name)";
- my @class = ('X', grep {$_} $prop, $script);
+sub range_cell {
+ my ($info, $offset) = @_;
+ my $table = $info->{cell} or return;
+ my $def = $table->{$offset} or return;
+ my ($len, $class, $name, $title) = @{$def};
- $glyph = "$glyph" if $prop eq 'Zs';
+ my $cols = $info->{cols};
+ my $colsize = $table->{colsize} || 1;
+ my $attr = '';
+ $len /= $colsize;
+ $name //= $len <= 2 ? 'res' : 'reserved';
- printf "\n".' | %s',
- join(' ', @class), quote($desc), $glyph;
+ if (my $part = $offset/$colsize % $cols) {
+ # continued row
+ my $rest = $cols - $part; # remaining
+ $rest = $len if $len < $rest; #TODO: optimise
+ if ($len -= $rest) {
+ # continued on new row
+ my @next = ($len * $colsize, "$class joinu");
+ if ($len > $rest) {
+ # minority remains
+ push @next, $name, $title;
+ $title ||= $name;
+ $name = '';
+ }
+ else {
+ # minority on next row
+ push @next, '"', $title || $name;
+ }
+ $table->{$offset + $colsize*$rest} //= \@next;
+ $class .= ' joind';
}
- print "\n";
+ $len = $rest;
}
- print " |
---|