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