keyboard: generic subpage include, specifics in metadata
[sheet.git] / keyboard.eng.inc.pl
1 use utf8;
2 use Unicode::Normalize qw( NFKD );
3 use Text::Unidecode qw( unidecode );
4
5 my @usintrows = (
6         [  'a' ..                                            'z'],
7         [qw(Á B ¢ Ð É F G H Í J Œ Ø µ Ñ Ó Ö Ä ® § Þ Ú V Å X Ü Æ)],
8         [qw(á b © ð é f g h í j œ ø µ ñ ó ö ä ® ß þ ú v å x ü æ)],
9         [qw(Å ı Ç ð ´ ̉ ˝ ̣ ˆ ½  Þ ¾ ˜ Ø ∏ Œ ‰ / ˇ ¨ ◊ „ ˛ ¼ ¸)],
10         [qw(å ∫ ç ∂ ́ ƒ © ˙ ̂ ∆ ° ¬ µ ̃ ø π œ ® ß † ̈ √ ∑ ≈ ¥ Ω)],
11 );
12 my @usint = (
13         map {
14                 my $c = $_;
15                 [ map { $usintrows[$_]->[$c] } 0 .. 2 ]
16         } 0 .. $#{ $usintrows[0] }
17 );
18
19 {
20         title => 'keyboard',
21         version => '1.2',
22         description => [
23                 "Windows US international keyboard layout table",
24                 "with the AltGr modifier key.",
25         ],
26         intro => 'Special <a href="/unicode">characters</a> returned with the AltGr modifier
27 for the Windows US international layout.',
28         rows => [0],
29
30         def => {
31                 '' => {
32                         map {
33                                 my @row = @{$_};
34                                 my $class = (
35                                           !defined $row[2] || $row[0] eq $row[2] ? 1 # identical
36                                         : $row[2] =~ /\A\p{Mn}+\z/ ? 8 # combining accent
37                                         : NFKD($row[2]) =~ $row[0] ? 2 # decomposed equivalent
38                                         : $row[2] =~ /^\p{Latin}/ ? 4 # latin script
39                                         : unidecode($row[2]) =~ /^\W*\Q$row[0]/ ? 5 # transliterated
40                                         : 7
41                                 );
42                                 $row[0] => "g$class"
43                         } @usint
44                 },
45         },
46         key => {
47                 map {
48                         $_->[0] => "$_->[1]<br>$_->[2]"
49                 } @usint
50         },
51         flag => {
52                 g1 => ['unaltered', "same results as without modifier"],
53                 g2 => ['accented', "decomposes to the original letter with a combining accent"],
54                 g4 => ['latin', "a different (accented) latin letter"],
55                 g5 => ['similar', "transliterates (mostly) into the unmodified letter"],
56                 g7 => ['other', "symbol not directly deducible from key"],
57                 g8 => ['combining', "diacritical mark to be combined with a following character"],
58         },
59 }