unicode: prefer shorter digraph codes
[sheet.git] / cc.plp
1 <:
2 use utf8;
3 use strict;
4 use warnings;
5 use open IO => ':utf8';
6
7 our $VERSION = 'v1.0';
8
9 $header{content_type} = 'text/html; charset=utf-8';
10
11 :><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
12  "http://www.w3.org/TR/html4/loose.dtd">
13 <html>
14
15 <head>
16 <title>country code cheat sheet</title>
17 <meta http-equiv="content-type" content="utf-8">
18 <link rel="stylesheet" type="text/css" media="all" href="/base.css">
19 </head>
20
21 <body>
22 <h1>Country codes</h1>
23
24 <:
25 my $cc = do 'cc.inc.pl';
26
27 sub quote {
28         local $_ = shift;
29         s/"/&quot;/g;
30         s/</&lt;/g;
31         s/>/&gt;/g;
32         return $_;
33 }
34
35 {
36         printf '<table class="glyphs ccmap">';
37         print '<col>';
38         for my $section (qw{thead}) {
39                 print "<$section><tr><th>↱";
40                 print '<th>', $_ for 'a' .. 'z';
41                 print "\n";
42         }
43         print '<tbody>';
44         for my $row ('a' .. 'z') {
45                 print '<tr><th>', $row;
46                 for my $col ('a' .. 'z') {
47                         my $code = $row . $col;
48                         my $country = $cc->{$code} or do {
49                                 print $code =~ /^x|^q[m-z]|^aa|^zz/ ? '<td class="X Co">' : '<td>';
50                                 next;
51                         };
52                         $code = $country->[2] if defined $country->[2];
53                         my $img = sprintf '<img src="/flag/%s.png" alt="%s">', $code, $code
54                                 if -e "flag/$code.png";
55                         printf "\n".'<td class="%s" title="%s">%s',
56                                 $img ? 'X '.$country->[1] : '', quote($country->[0]), $img;
57                 }
58                 print "\n";
59         }
60         print "</table>\n";
61 }
62
63 :>
64 <hr>
65
66 <div class="legend">
67         <table class="glyphs"><tr>
68         <td class="X c-af">africa
69         <td class="X c-eu">europe
70         <td class="X c-as">asia
71         <td class="X c-oc">oceania
72         <td class="X c-aa">antarctica
73         <td class="X c-sa">south america
74         <td class="X c-na">north america
75         <td class="X Xi">reserved
76         <td class="X Co">user-assigned
77         </table>
78 </div>
79
80 <p class="footer">
81         <a href="/" rel="home">sheet.shiar.nl</a>/charset
82         <a href="git://git.shiar.nl/sheet" rel="vcs-git" title="Git repository"><:= $VERSION :></a>
83         created by <a href="http://shiar.nl/" rel="author">Shiar</a> •
84         <a title="Licensed under the GNU Affero General Public License, version 3" rel="copyright"
85            href="http://www.fsf.org/licensing/licenses/agpl-3.0.html">AGPLv3</a>
86 </p>
87
88 </html>