X-Git-Url: http://git.shiar.net/sheet.git/blobdiff_plain/a0ba9298856b2426c5c66b6d2f2b284d98cee594..72d7fa29bef747722a947e079ceac1a21e12acc6:/charset.plp diff --git a/charset.plp b/charset.plp index c9ef2b6..d3b27b5 100644 --- a/charset.plp +++ b/charset.plp @@ -1,185 +1,230 @@ -<: -use utf8; -use strict; -use warnings; -use open IO => ':utf8'; - -our $VERSION = '1.0'; - -$header{content_type} = 'text/html; charset=utf-8'; - -:> - +<(common.inc.plp)><: + +Html({ + title => 'charset cheat sheet', + version => '1.0', + description => [ + "Reference sheet with all glyphs in common character encoding tables,", + "and an overview of Unicode ranges and UTF-8 bytes.", + ], + keywords => [qw' + charset codepage unicode ascii utf8 latin glyph character encoding + reference common overview table + '], + stylesheet => [qw'light'], + data => [qw'charset-unicode.inc.pl charset-utf8.inc.pl'], +}); -
-$inputunknown"); + } + $row{set} ? \%row : (); + } + else { + (); + } +} map { defined $ALIAS{$_} ? @{ $ALIAS{$_} } : $_ } + $Request =~ /\w/ ? split(m{[/+\s]}, $Request) : 'default'; my $NOCHAR = chr 0xFFFD; -for my $cp437 (grep {$request[$_] eq 'cp437'} 0 .. $#request) { - substr($tables[$cp437], 237, 1) = pack 'U*', 0x3D5; # phi sign - substr($tables[$cp437], 0, 32) = pack 'U*', map {hex} qw( +for my $cp437 (grep {$request[$_]->{set} eq 'cp437'} 0 .. $#request) { + substr($request[$cp437]->{table}, 237, 1) = pack 'U*', 0x3D5; # phi sign + substr($request[$cp437]->{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 ); } -sub quote { - local $_ = shift; - s/"/"/g; - s/</g; - s/>/>/g; - return $_; -} - -print "
â±"; - print ' | ', $_ for @nibble; - print "\n"; +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; } - print ' | |
---|---|---|
', $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}; - } - 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; + 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'; } - print "\n"; + $attr .= sprintf ' rowspan=%d', $rows; + $len = 16; } - print " |
â±"; print ' | ', $_ for @nibble; print "\n"; } 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 $value = ($msb<<4) + $lsb; - if ($value <= 0x7F) { - print ' | Single byte ASCII' - if $value == 0; - } - elsif ($value <= 0xBF) { - print ' | Multi-byte continuation' - if $value == 0x80; - } - elsif ($value <= 0xC1) { - print ' | (Overl.)' - if $value == 0xC0; - } - elsif ($value <= 0xDF) { - print ' | 2-byte sequence start' - if $value == 0xC2; - print ' | ' - if $value == 0xD0; - } - elsif ($value <= 0xEF) { - print ' | 3-byte sequence start' - if $value == 0xE0; - } - elsif ($value <= 0xF4) { - print ' | 4-byte sequence' - if $value == 0xF0; - } - elsif ($value <= 0xF7) { - print ' | (Overflow)' - if $value == 0xF5; - } - elsif ($value <= 0xFB) { - print ' | 5-byte' - if $value == 0xF8; - } - elsif ($value <= 0xFD) { - print ' | 6-byte' - if $value == 0xFC; - } - elsif ($value <= 0xFF) { - print ' | Invalid' - if $value == 0xFE; + 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; } - else { - print "\n".' | ?'; + + my $glyph = substr $row->{table}, $val, 1; + if ($glyph eq $NOCHAR) { + print ' | '; + next; } + + print "\n".$glyphs->glyph_cell($glyph); } print "\n"; } - print " |
control + | whitespace + | diacritic
| punctuation
| symbol
| numeric + | greek
| aramaic
| syllabic
| alphabetic + |
unicode 7.0 + | proposed + | deprecated + | unassigned + | invalid + |