dd7de6d2fe3f8f2825b425e1b96d656908599ce8
[sheet.git] / unicode.plp
1 <:
2 use utf8;
3 use strict;
4 use warnings;
5 no  warnings 'qw';  # that's not a comment, it's a NUMBER SIGN
6 use open IO => ':utf8';
7
8 our $VERSION = '1.0';
9
10 $header{content_type} = 'text/html; charset=utf-8';
11
12 :><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
13  "http://www.w3.org/TR/html4/loose.dtd">
14 <html>
15
16 <head>
17 <title>digraph cheat sheet</title>
18 <meta http-equiv="content-type" content="utf-8">
19 <link rel="stylesheet" type="text/css" media="all" href="/digraphs.css">
20 <link rel="vcs" type="git" href="git://dev.shiar.nl/sheet">
21 </head>
22
23 <body>
24 <h1>Common uncommon Unicode</h1>
25
26 <p>i^k in <a href="/">Vim</a>.
27 Also see the <a href="/digraphs">complete digraphs table</a>.</p>
28
29 <div class="diinfo">
30
31 <:
32 my $diinfo = do 'digraphs.inc.pl';
33 my %di = map { $diinfo->{$_}->[0] => $_ } grep { ref $diinfo->{$_} }
34         keys %$diinfo;
35
36 sub quote {
37         local $_ = shift;
38         s/"/&quot;/g;
39         s/</&lt;/g;
40         s/>/&gt;/g;
41         return $_;
42 }
43
44 sub glyph_table {
45         my ($digraphs) = @_;
46
47         my @rows;
48
49         my @colheads;
50         while ($digraphs->[0] !~ /^\./) {
51                 my $cell = shift @$digraphs or last;
52                 push @colheads, sprintf(
53                         '<%s%s>%s',
54                         $cell =~ s/^-// ? 'td' : 'th',
55                         $cell =~ s/:(.*)// ? qq{ title="$1"} : '',
56                         $cell eq '_' ? '&nbsp;' : $cell
57                 );
58         }
59         push @rows, sprintf '<thead><tr>%s<tbody>', join '', @colheads if @colheads;
60
61         my $colspan = 1;
62         for my $cell (@$digraphs) {
63                 if ($cell =~ s/^\.//) {
64                         # dot indicates start of a new row
65                         push @rows, '';
66                         if ($cell =~ s/^>//) {
67                                 # header cell text follows
68                                 $cell =~ s/_/ /g;  # underscores may be used instead of whitespace (for qw//ability)
69                                 $rows[-1] .= '<th>'.($cell || '&nbsp;');
70                         }
71                         next;
72                 }
73                 elsif ($cell eq '>') {
74                         # merge this cell to the next column
75                         $colspan++;
76                         next;
77                 }
78
79                 my $code = join '', map { $di{ord $_} || '' } split //, $cell;
80                 my $name = $diinfo->{$code}->[1];
81
82                 # determine display class
83                 my @class;
84                 if ($cell eq '-') {
85                         $cell = '';
86                 }
87                 elsif ($cell eq '=') {
88                         push @class, 'di-invalid';
89                         $cell = '';
90                 }
91                 else {
92                         if ($cell =~ s/^-//) {
93                                 push @class, 'di-rare'; # discouraged
94                         }
95
96                         if ($code) {
97                                 push @class, 'di-d'; # digraph
98                                 push @class, 'di-prop' # unofficial
99                                         if $diinfo->{$code}->[2] =~ /\bXz\b/;
100                         }
101
102                         if ($cell =~ /[ -~]/) {
103                                 push @class, 'di-a'; # ascii
104                         }
105                         else {
106                                 push @class, 'di-b'; # basic unicode
107                         }
108                 }
109
110                 # add cell html
111                 $rows[-1] .= sprintf('<td%s%s%s>%s%s',
112                         defined $name  ? qq{ title="$name"}  : '',
113                         @class ? sprintf(' class="%s"', join ' ', @class) : '',
114                         $colspan > 1 && qq{ colspan="$colspan"},
115                         $cell eq '' ? '&nbsp;' : quote($cell),
116                         $code ne '' ? sprintf(' <small class="digraph">%s</small>', quote($code))
117                                 : length($cell) == 1 && $cell !~ /[a-z]/
118                                         ? sprintf(' <small class="%s">%04X</small>', 'value', ord $cell)
119                                         : '',
120                 );
121
122                 $colspan = 1;
123         }
124
125         return sprintf qq{<table class="glyphs dilabel">\n%s</table>\n},
126                 join '', map {"<tr>$_\n"} @rows;
127 }
128
129 sub print_glyph_tables {
130         while (@_) {
131                 printf "<div><h2>%s</h2>\n\n", shift;
132                 while (ref $_[0] and $_ = shift) {
133                         print glyph_table($_);
134                 }
135                 print '</div>';
136         }
137 }
138
139 print_glyph_tables(
140         'Popular',
141         [qw{. « » . ‹ › . ‘ ’ . “ ” . „ ‚ . ‟ ‛}],
142         [qw{. † ‡ • . § ¶ # . © ® ™ . ° ′ ″ . − × ÷ . ± ² √}],
143         [qw{. å ä ö ü ß . Å æ ø ű ſ}],
144         [qw{. ¿ ç ñ é ê è}],
145
146         'Arrows',
147         [qw{. ↖ ↑ ↗ ↔ . ← - → ↕ . ↙ ↓ ↘ -}],
148         [qw{. ⇖ ⇑ ⇗ ⇔ . ⇐ - ⇒ ⇕ . ⇙ ⇓ ⇘ -}],
149         [qw{. ◤ ▲ ◥   . ◀ ◆ ▶   . ◣ ▼ ◢  }],
150         [qw{. ◸ △ ◹   . ◁ ◇ ▷   . ◺ ▽ ◿  }],
151
152         'Line drawing',
153         [qw{. ┌ ┬ ┐ . ├ ┼ ┤ . └ ┴ ┘}],
154         [qw{. ┏ ┳ ┓ . ┣ ╋ ┫ . ┗ ┻ ┛}],
155         [qw{. ┍ ┯ ┑ . ┝ ┿ ┥ . ┕ ┷ ┙}],
156         [qw{. ┎ ┰ ┒ . ┠ ╂ ┨ . ┖ ┸ ┚}],
157         [qw{
158                 . ╴ ─ ╌ ┄ ┈ ╶ ╾
159                 . ╸ ━ ╍ ┅ ┉ ╺ ╼
160                 . ╵ │ ╎ ┆ ┊ ╷ ╿
161                 . ╹ ┃ ╏ ┇ ┋ ╻ ╽
162         }],
163         [qw{. ╱ ╳ ╲ }],
164         [qw{. ╔ ╦ ╗ ═ . ╠ ╬ ╣ ║ . ╚ ╩ ╝ - }],
165         [qw{. ╒ ╤ ╕ . ╞ ╪ ╡ . ╘ ╧ ╛ }],
166         [qw{. ╓ ╥ ╖ . ╟ ╫ ╢ . ╙ ╨ ╜ }],
167
168         'Blocks',
169         [qw{. ▘ ▀ ▝ . ▌ █ ▐ . ▖ ▄ ▗ }],
170         [qw{. ░ . ▒ . ▓ }],
171         [qw{. ▛ ▚ ▟ . ▙ ▞ ▜ }],
172         [qw{. ▁ ▂ ▃ ▄ ▅ ▆ ▇ ▔ . ▏ ▎ ▍ ▌ ▋ ▊ ▉ ▕ }],
173         [qw{. □ ▣ ■ . ▤ ▦ ▥ . ▧ ▩ ▨}],
174
175         'Signs',
176         [qw{. ¤ ¢ ₥ € £ ₨ $ ¥ . ₫ ₭ ₦ ₱ ₧ ₮ ₩ ₪}],
177         [qw{. ♠ ♡ ♢ ♣ . ♤ ♥ ♦ ♧}],
178         [qw{. ☉ ☿ ♀ ♁ ♂ ♃ ♄ ♅ ♆ ♇}],  # solar
179         [qw{. ♈ ♉ ♊ ♋ ♌ ♍ ♎ ♏ ♐ ♑ ♒ ♓}],  # zodiac
180
181         'IPA',
182         [qw{
183                 - BiL:Bilabial LD:Labiodental D:Dental Alv:Alveolar PA:Postalveolar
184                   Rf:Retroflex Pal:Palatal Vel:Velar Uv:Uvular Ph:Pharyngeal
185                   EG:Epiglottal Gl:Glottal
186                 .>Plosive                   p  -ȹ >  >  t  ʈ  c  k  q  =  ʡ  ʔ
187                 .>Voiced_Plosive            b  -ȸ >  >  d  ɖ  ɟ  ɡ  ɢ  =  -  =
188                 .>Nasal                     m  ɱ  >  >  n  ɳ  ɲ  ŋ  ɴ  =  =  =
189                 .>Trill                     ʙ  -  >  >  r  -  -  =  ʀ  =  -я =
190                 .>Tap/flap                  -  ⱱ  >  >  ɾ  ɽ  -  =  ɢ̆  =  -  =
191                 .>Fricative                 ɸ  f  θ  s  ʃ  ʂ  ç  x  χ  ħ  ʜ  h
192                 .>Voiced_fricative          β  v  ð  z  ʒ  ʐ  ʝ  ɣ  ʁ  ʕ  ʢ  ɦ
193                 .>Lateral_fricative         =  =  >  >  ɬ  -  -  -  -  =  =  =
194                 .>Voiced_lateral_fricative  =  =  >  >  ɮ  -  -  -  -  =  =  =
195                 .>Approximant               -  ʋ  >  >  ɹ  ɻ  j  ɰ  -  -  -  =
196                 .>Lateral_approximant       =  =  >  >  l  ɭ  ʎ  ʟ  -  =  =  =
197                 .>Click                     ʘ  -  ǀ  ǁ  ǃ  -‼ ǂ  -  -  =  =  =
198                 .>Implosive                 ɓ  ɗ̪  >  >  ɗ  -ᶑ ʄ  ɠ  ʛ  =  =  =
199         }],
200         [qw{
201                 co . ɕ . ʑ . ɧ . ɥ . ʍ . w
202         }],
203         [(
204                 '-',
205                 map { substr($_, 0, 1).':'.$_, substr($_, 0, 1)." r:$_ rounded" }
206                 qw{Front Central Back}
207         ), qw{
208                 .>Close      i y  ɨ ʉ  ɯ u
209                 .>Near-close ɪ ʏ  - -  - ʊ
210                 .>Close-mid  e ø  ɘ ɵ  ɤ o
211                 .>Mid        - -  ə -  - -
212                 .>Open-mid   ɛ œ  ɜ ɞ  ʌ ɔ
213                 .>Near-open  æ -  ɐ -  - -
214                 .>Open       a ɶ  - -  ɑ ɒ
215         }],
216
217         'Alphabetics',
218         [qw{
219                 .>Latin    a ī ı ę ô ɳ ŋ ṡ š đ ð Ʒ
220                 .>Cyrillic а і й э ё н њ ш щ ч ь Я
221                 .>Greek    α ί ϊ η ϋ π ψ σ ς θ ξ Ω
222                 .>Hebrew   א ײ י ע ו נ ן ס ש ט צ ץ
223         }],
224
225         'Japanese',
226         [qw{
227                   - A  I  U  E  O  _
228                 .>  あ い う え お =
229                 .>K か き く け こ =
230                 .>S さ し す せ そ =
231                 .>T た ち つ て と =
232                 .>N な に ぬ ね の ん
233                 .>H は ひ ふ へ ほ =
234                 .>M ま み む め も =
235                 .>Y や =  ゆ =  よ =
236                 .>R ら り る れ ろ =
237                 .>W わ -ゐ = -ゑ を =
238         }],
239         [qw{
240                   - A  I  U  E  O
241                 .>G が ぎ ぐ げ ご
242                 .>Z ざ じ ず ぜ ぞ
243                 .>D だ ぢ づ で ど
244                 .>B ば び ぶ べ ぼ
245                 .>P ぱ ぴ ぷ ぺ ぽ
246         }],
247         [qw{
248                   - A  I  U  E  O  _
249                 .>  ア イ ウ エ オ ー
250                 .>K カ キ ク ケ コ =
251                 .>S サ シ ス セ ソ =
252                 .>T タ チ ツ テ ト =
253                 .>N ナ ニ ヌ ネ ノ ン
254                 .>H ハ ヒ フ ヘ ホ =
255                 .>M マ ミ ム メ モ =
256                 .>Y ヤ -  ユ -  ヨ =
257                 .>R ラ リ ル レ ロ =
258                 .>W ワ ヰ -  ヱ ヲ =
259         }],
260         [qw{
261                   - A  I  U  E  O
262                 .>G ガ ギ グ ゲ ゴ
263                 .>Z ザ ジ ズ ゼ ゾ
264                 .>D ダ ヂ ヅ デ ド
265                 .>B バ ビ ブ ベ ボ
266                 .>P パ ピ プ ペ ポ
267                 .>V ヷ ヸ ヴ ヹ ヺ
268         }],
269 );
270
271 :></div>
272
273 <div id="legend">
274         <table class="glyphs"><tr>
275         <td class="X di-a">ascii
276         <td class="X di-d">digraph
277         <td class="X di-prop">proposed
278         <td class="X di-b">other unicode
279         <td class="X di-rare">discouraged
280         </table>
281 </div>
282
283 <p id="footer">
284         <a href="http://sheet.shiar.nl/unicode">sheet.shiar.nl<strong>/unicode</strong></a>
285         <a href="git://dev.shiar.nl/sheet"><:= "v$VERSION" :></a>
286         created by Shiar •
287         <a title="Licensed under the GNU Affero General Public License, version 3"
288            href="http://www.fsf.org/licensing/licenses/agpl-3.0.html">AGPLv3</a> •
289         last update <:
290                 use Time::Format qw(time_format);
291                 print time_format('yyyy-mm-dd', (stat $ENV{SCRIPT_FILENAME})[9]);
292         :>
293 </p>
294
295 </html>