<: use utf8; use strict; use warnings; use open IO => ':utf8'; our $VERSION = '1.0'; $header{content_type} = 'text/html; charset=utf-8'; :> charset cheat sheet

Character encoding

<: my $diinfo = do 'digraphs.inc.pl'; my %di = map { $diinfo->{$_}->[0] => $_ } grep { ref $diinfo->{$_} } keys %$diinfo; use Encode qw(decode); # generate character table(s) # (~16x faster than decoding in loop; # substr strings is twice as fast as splitting to an array) my @tables = map { decode($_, pack 'C*', 0..255) } 'iso-8859-1'; my $NOCHAR = chr 0xFFFD; sub quote { local $_ = shift; s/"/"/g; s//>/g; return $_; } my @nibble = (0..9, 'A'..'F'); for my $table (@tables) { print ''; for my $section (qw{thead tfoot}) { print "<$section>'; for my $msb (0 .. $#nibble) { print '
↳"; print '', $_ for @nibble; print " \n"; } print '
', $nibble[$msb]; for my $lsb (0 .. $#nibble) { my $glyph = substr $table, ($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; } print "\n", $nibble[$msb], "\n"; } print "
\n"; }