X-Git-Url: http://git.shiar.nl/sheet.git/blobdiff_plain/a0ba9298856b2426c5c66b6d2f2b284d98cee594..99e52849c6eebe4caa1018e960054d663352dd5d:/charset.plp diff --git a/charset.plp b/charset.plp index c9ef2b6..c89c924 100644 --- a/charset.plp +++ b/charset.plp @@ -1,185 +1,521 @@ -<: -use utf8; -use strict; -use warnings; -use open IO => ':utf8'; - -our $VERSION = '1.0'; +<(common.inc.plp)><: -$header{content_type} = 'text/html; charset=utf-8'; +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'], +}); -:> - +my @tablist = split m{/+}, $Request || 'default'; - -charset cheat sheet - - - +use List::Util qw( first pairmap pairfirst pairs ); - -

Character encoding

+:> +

Character encodings

+

<: -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 @request = ('iso-8859-1', 'cp437'); -my @tables = map { decode($_, pack 'C*', 0..255) } @request; -my $NOCHAR = chr 0xFFFD; +if ($tablist[0] eq 'default') { + say "Overview of Unicode allocation and common latin code pages."; + say "Compare alternate charsets:"; +} +else { + say "Charset comparison:"; +} -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( - 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 optionlink { + my ($title, $href, $selected) = @_; + return sprintf( + $selected ? '%s' : '%s', + EscapeHTML($title), $href ); } -sub quote { - local $_ = shift; - s/"/"/g; - s//>/g; - return $_; -} +print join " •\n", ( + map { + join " ·\n", pairmap { + optionlink($b || ucfirst $a, '/charset'.($a && "/$a?compare"), $a eq $Request); + } @{$_} + } + [ + iso => 'ISO', + win => 'Windows', + dos => 'DOS', + mac => 'Apple', + ebcdic => 'EBCDIC', + $tablist[0] eq 'default' ? () : ('' => 'common'), + ], + [ + westeur => 'West', + centeur => 'Central', + norteur => 'North European', + turkish => 0, + greek => 0, + cyrillic => 0, + hebrew => 0, + ], +); +:>. +

-print "\n"; - :>
- +
+ <: if (exists $get{compare}) { :> +
unicode + inherited + existing + original + unassigned +<: } else { :> + control + whitespace + diacritic +
letter +
+
punctuation +
quote +
+
symbol +
math + currency +
+
numeric + greek +
latin + cyrillic +
+
aramaic +
brahmic + arabic +
+
syllabic +
african + japanese + cjk + chinese +
+
alphabetic +
+ + +
unicode 7.0 + proposed + deprecated + unassigned + invalid +<: } :>
+
-