\n";
+ 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';
+ }
+ $len = $rest;
+ }
+ elsif (my $rows = int($len / $cols)) {
+ # multiple full rows
+ if ($len -= $rows * $cols) {
+ # partial row remains
+ $table->{$offset + $colsize*$rows * $cols} //= [$len*$colsize, "$class joinu", '', $title];
+ $class .= ' joind';
+ }
+ $attr .= sprintf ' rowspan=%d', $rows;
+ $len = $cols;
+ }
+
+ $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";
+}
-my @nibble = (0..9, 'A'..'F');
for my $row (@request) {
- printf '', !$row->{cell} && ' charmap';
- printf '%s', $row->{set};
- print '';
+ my $cols = $row->{cols};
+ my $colsize = $row->{cell} && $row->{cell}->{colsize} || 1;
+ my $coldigits = ceil(log($colsize * $cols) / log(16)); # uniform length of hexadecimal header
+ my $rowdiv = 16 ** $coldigits; # row divide for column digits
+ $rowdiv = 1 if $rowdiv != $cols * $colsize; # divide only if all columns are matched
+ my $offset = 0;
+
+ printf '', !$row->{cell} && ' charmap';
+ my $title = $row->{set};
+ $title .= " "
+ for grep { $_ ne 'iso-8859-1' } $row->{parent} // ();
+ printf '%s', $title;
+ print '' x ($cols + 1);
for my $section (qw{thead}) {
- print "<$section>â±";
- print ' | ', $_ for @nibble;
+ print "<$section> |
---|
", $rowdiv == 1 ? '+' : 'â±';
+ printf ' | %0*X', $coldigits, $_ * $colsize for 0 .. $cols - 1;
print "\n";
}
print ' | ';
- for my $msb (0 .. (length($row->{table}) || 256) - 1 >> 4) {
- printf '%X', $msb + ($row->{offset} >> 4);
- for my $lsb (0 .. $#nibble) {
+ while ($offset < $row->{endpoint}) {
+ if ($row->{skip}->{$offset}) {
+ $offset += $cols * $colsize;
+ next;
+ }
+
+ print ' |
---|
';
+ {
+ if (my $rowmod = $offset % $rowdiv) {
+ # offset in column units
+ printf '+%X', $rowmod;
+ }
+ else {
+ # divided row offset
+ printf '%X', ($offset + $row->{offset}) / $rowdiv;
+ }
+ }
+ for (1 .. $cols) {
if ($row->{cell}) {
- print $row->{cell}->(($msb<<4) + $lsb);
+ print range_cell($row, $offset);
next;
}
- my $glyph = substr $row->{table}, ($msb<<4) + $lsb, 1;
+ my $glyph = ref $row->{table} eq 'ARRAY' ? $row->{table}->[$offset] :
+ substr $row->{table}, $offset, 1;
if ($glyph eq $NOCHAR) {
print ' | ';
next;
}
- my $info = [ord $glyph];
- if (defined (my $mnem = $di{ord $glyph})) {
- $info = $diinfo->{$mnem};
+ if (exists $get{compare}) {
+ state $visible = {};
+ my $cp = $offset + $row->{offset};
+ printf ' | %2$s',
+ $cp == ord $glyph ? 'l4' :
+ $row->{parent} && $glyph eq
+ Encode::decode($row->{parent}, pack 'C', $cp) ? 'l3' :
+ $visible->{$glyph} ? 'l2' :
+ 'l1',
+ $glyphs->glyph_html($glyph);
+ $visible->{$glyph}++;
+ next;
}
- 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);
+ }
+ continue {
+ $offset += $colsize;
}
print "\n";
}
- print " |
---|
\n";
+ say ' ';
}
-print "\n";
-
:>
-
+ <: if (exists $get{compare}) { :>
+ unicode
+ | inherited
+ | existing
+ | original
+ | unassigned
+<: } else { :>
| control
| whitespace
| diacritic
@@ -194,24 +419,11 @@ print "\n";
- unicode 5.0
+ | unicode 7.0
| proposed
| deprecated
| unassigned
| invalid
- |
+<: } :> |
-
-
-
|