charset: unmultiplied unicode ranges
[sheet.git] / charset.plp
index 080e2085417c607035390b351bd7340e32286b5a..118658569014cd082cc4f2e532678d6052f78867 100644 (file)
@@ -19,6 +19,7 @@ Html({
 <h1>Character encoding</h1>
 
 <:
+use POSIX qw( ceil );
 use Shiar_Sheet::FormatChar;
 my $glyphs = Shiar_Sheet::FormatChar->new;
 my $cols = 16;  # columns
@@ -162,7 +163,7 @@ for my $row (@request) {
        $title .= " <aside>($_)</aside>" for $row->{setnote} // ();
        printf '<caption>%s</caption>', $title;
        print '<col>' x ($cols + 1);
-       my $coldigits = $colsize * $cols <= 16 ? 1 : 2;  # uniform length of hexadecimal header
+       my $coldigits = ceil(log($colsize * $cols) / log(16));  # uniform length of hexadecimal header
        for my $section (qw{thead}) {
                print "<$section><tr><th>↱";
                printf '<th>%0*X', $coldigits, $_ * $colsize for 0 .. $cols - 1;