df1d3f01ffd60ef6f24a4686c5f2d1c1f4df59b1
[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         def => {
21                 '' => {
22                         map {
23                                 my @row = @{$_};
24                                 my $class = (
25                                           !defined $row[2] || $row[0] eq $row[2] ? 1 # identical
26                                         : $row[2] =~ /\A\p{Mn}+\z/ ? 8 # combining accent
27                                         : NFKD($row[2]) =~ $row[0] ? 2 # decomposed equivalent
28                                         : $row[2] =~ /^\p{Latin}/ ? 4 # latin script
29                                         : unidecode($row[2]) =~ /^\W*\Q$row[0]/ ? 5 # transliterated
30                                         : 7
31                                 );
32                                 $row[0] => "g$class"
33                         } @usint
34                 },
35         },
36         key => {
37                 map {
38                         $_->[0] => "$_->[1]<br>$_->[2]"
39                 } @usint
40         },
41         flag => {
42                 g1 => ['unaltered', "same results as without modifier"],
43                 g2 => ['accented', "decomposes to the original letter with a combining accent"],
44                 g4 => ['latin', "a different (accented) latin letter"],
45                 g5 => ['similar', "transliterates (mostly) into the unmodified letter"],
46                 g7 => ['other', "symbol not directly deducible from key"],
47                 g8 => ['combining', "diacritical mark to be combined with a following character"],
48         },
49 }