keyboard/altgr: declare further similar characters
[sheet.git] / Shiar_Sheet / KeyboardChars.pm
index 6afd7dce4cf1b7619d9aff5b9ab0e784692fc812..7290b5d8f76af7b60bb215f8c81b008f6d33e187 100644 (file)
@@ -2,17 +2,29 @@ package Shiar_Sheet::KeyboardChars;
 
 use 5.020;
 use warnings;
+use utf8;
 use experimental 'signatures';
 use parent 'Exporter';
 use Unicode::Normalize qw( NFKD );
-use Text::Unidecode qw( unidecode );
+use Text::Unidecode ();
 use Shiar_Sheet::FormatChar;
 
-our $VERSION = '1.00';
+our $VERSION = '1.02';
 our @EXPORT = qw( kbchars kbmodes );
 
 my $uc = Shiar_Sheet::FormatChar->new;
 
+our %unaccent = qw(
+       ⍺ a  ⍵ w  ∊ E  ⍷ E  ⍴ r  ⍳ i  ⍸ i  ○ O  ⍥ O  ⌿ /  ⍟ (*) ⊕ (+)
+       Ʊ U  ǝ e  Ǝ E  ʌ v  χ X  ɥ h  ʘ O  ɰ mw ɯ mw Ɯ MW ə @ae Ə @AE
+       ɸ PF ʎ yl ɔ co Ɔ CO ɛ 3E ƣ q  Ƣ Q  ∀ A  ∃ E  ∪ u  ∩ n   ≠ !=
+       ≈ =~ ∅ /0 ∘ o  ⋅ .  ∫ s  ≝ =d ″ "  ≤ <  ≥ >  √ rV ∛ 3V  ∜ 4V
+);
+
+sub unidecode {
+       return $unaccent{$_[0]} // Text::Unidecode::unidecode($_[0]);
+}
+
 sub kbchars ($rows) {
        return kbmodes({'' => $rows});
 }
@@ -36,10 +48,10 @@ sub kbmodes ($modes) {
                        my $class = 'g'.(
                                  !defined $v || $c eq $v ? 1 # identical
                                : $v =~ /\A\p{Mn}+\z/ ? 9 # combining accent
-                               : $v =~ /\A[\p{Sk}\p{Lm}]+\z/ ? 8 # modifier symbol
-                               : $v =~ /\A[\pM\pP]+\z/ ? 7 # mark
                                : NFKD($v) =~ /\Q$c/ ? 2 # decomposed equivalent
                                : unidecode($v) =~ /\Q$c\E+/i ? 4 # transliterated
+                               : $v =~ /\A[\p{Sk}\p{Lm}]+\z/ ? 8 # modifier symbol
+                               : $v =~ /\A[\pM\pP]+\z/ ? 7 # mark
                                : $v =~ /^\p{Latin}/ ? 5 # latin script
                                : 6
                        );