â³";
+sub range_cell {
+ my ($table, $offset) = @_;
+ my $def = $table->{$offset} or return;
+ my ($len, $class, $name, $title) = @{$def};
+
+ my $attr = '';
+ $len /= $nibsize;
+ $name //= $len <= 2 ? 'res' : 'reserved';
+
+ if (my $part = $offset/$nibsize % 16) {
+ # continued row
+ my $cols = 16 - $part; # remaining
+ $cols = $len if $len < $cols; #TODO: optimise
+ if ($len -= $cols) {
+ # continued on new row
+ $table->{$offset + $nibsize*$cols} //= [$len*$nibsize, "$class joinu", $name, $title];
+ $name = '';
+ $class .= ' joind';
+ }
+ $len = $cols;
+ }
+ elsif (my $rows = $len >> 4) {
+ # multiple full rows
+ if ($len -= $rows << 4) {
+ # partial row remains
+ $table->{$offset + $nibsize*$rows * 16} //= [$len*$nibsize, "$class joinu", '', $title];
+ $class .= ' joind';
+ }
+ $attr .= sprintf ' rowspan=%d', $rows;
+ $len = 16;
+ }
+
+ $attr .= sprintf ' colspan=%d', $len unless $len == 1;
+ $attr .= $1 if $class and $class =~ s/( \w+="[^"]*")//;
+ $attr .= sprintf ' class="%s"', $class if $class;
+ $attr .= sprintf ' title="%s"', EscapeHTML($title) if $title;
+ return " | $name";
+}
+
+for my $row (@request) {
+ printf '', !$row->{cell} && ' charmap';
+ my $title = $row->{set};
+ $title .= " " for $row->{setnote} // ();
+ printf '%s', $title;
+ print '' x 17;
+ for my $section (qw{thead}) {
+ print "<$section>â±";
print ' | ', $_ for @nibble;
- print " | \n";
+ print "\n";
}
print ' | ';
- for my $msb (0 .. $#nibble) {
- print '', $nibble[$msb];
+ for my $msb (0 .. (length($row->{table}) || 256) - 1 >> 4) {
+ printf ' |
---|
%X', ($msb + ($row->{offset} >> 4)) * $nibsize;
for my $lsb (0 .. $#nibble) {
- my $glyph = substr $table, ($msb<<4) + $lsb, 1;
+ my $val = ( ($msb<<4) + $lsb ) * $nibsize;
+ if ($row->{cell}) {
+ if (ref $row->{cell} eq 'CODE') {
+ print $row->{cell}->($val);
+ next;
+ }
+ print range_cell($row->{cell}, $val);
+ next;
+ }
+
+ my $glyph = substr $row->{table}, $val, 1;
if ($glyph eq $NOCHAR) {
print ' | ';
next;
}
- my $info = [ord $glyph];
- if (defined (my $mnem = $di{ord $glyph})) {
- $info = $diinfo->{$mnem};
- }
- my ($codepoint, $name, $prop, $script, $string) = @$info;
-
- $glyph = quote($string || $glyph);
- my $desc = sprintf 'U+%04X%s', $codepoint, $name && " ($name)";
- my @class = ('X', grep {$_} $prop, $script);
- $glyph = "$glyph" if $prop eq 'Zs';
-
- printf "\n".' | %s',
- join(' ', @class), quote($desc), $glyph;
+ print "\n".$glyphs->glyph_cell($glyph);
}
- print "\n | ", $nibble[$msb], "\n";
+ print "\n";
}
- print " |
---|
\n";
+ print " |
---|