use warnings;
use utf8;
use re '/msx';
+use open IO => ':encoding(utf-8)', ':std';
+use charnames ();
use JSON ();
use Data::Dump 'pp';
-our $VERSION = '1.00';
+our $VERSION = '1.02';
my $symname = eval {
open my $keysymh, '<', 'data/keysymdef.json' or die $!;
return JSON->new->decode(readline $keysymh);
} or die "Could not read keysym definitions: $@\n";
-my %geochar = (
- TLDE => ["`", "~"],
- AE01 => ['1', "!"],
- AE02 => ['2', "\@"],
- AE03 => ['3', "#"],
- AE04 => ['4', "\$"],
- AE05 => ['5', "%"],
- AE06 => ['6', "^"],
- AE07 => ['7', "&"],
- AE08 => ['8', "*"],
- AE09 => ['9', "("],
- AE10 => ['0', ")"],
- AE11 => ["-", "_"],
- AE12 => ["=", "+"],
-
- AD01 => ["q", "Q"],
- AD02 => ["w", "W"],
- AD03 => ["e", "E"],
- AD04 => ["r", "R"],
- AD05 => ["t", "T"],
- AD06 => ["y", "Y"],
- AD07 => ["u", "U"],
- AD08 => ["i", "I"],
- AD09 => ["o", "O"],
- AD10 => ["p", "P"],
- AD11 => ["[", "{"],
- AD12 => ["]", "}"],
-
- AC01 => ["a", "A"],
- AC02 => ["s", "S"],
- AC03 => ["d", "D"],
- AC04 => ["f", "F"],
- AC05 => ["g", "G"],
- AC06 => ["h", "H"],
- AC07 => ["j", "J"],
- AC08 => ["k", "K"],
- AC09 => ["l", "L"],
- AC10 => [";", ":"],
- AC11 => ["'", '"'],
-
- LSGT => ["§", "±"], # mac
- AB01 => ["z", "Z"],
- AB02 => ["x", "X"],
- AB03 => ["c", "C"],
- AB04 => ["v", "V"],
- AB05 => ["b", "B"],
- AB06 => ["n", "N"],
- AB07 => ["m", "M"],
- AB08 => [",", "<"],
- AB09 => [".", ">"],
- AB10 => ["/", "?"],
- BKSL => ["\\","|"],
-);
+my $geochar = do './keyspos.inc.pl'
+ or die "Could not read keyboard position names: $@\n";
my %res;
while (readline) {
elsif (defined $symname->{$chr}) {
$chr = $symname->{$chr};
}
+ elsif ($chr eq 'NoSymbol') {
+ next;
+ }
else {
warn "unknown symbol $chr at $pos\n";
}
- $res{$geochar{$pos}->[$shift] // $pos} = $chr;
+ $res{$geochar->{$pos}->[$shift] // $pos} = $chr;
#$res{$pos}[$shift] = $symname->{$chr} // $chr; # geochar
}
}
-say pp \%res;
+say ppp(\%res);
+
+sub ppp {
+ local $_ = pp(@_);
+ s/(?<=") \\x \{? ([0-9A-F]{2,6}) \}?/chr hex $1/eg; # unescape glyphs
+ s/(\p{Mn})/sprintf '\N{%s}', charnames::viacode(ord $1)/eg; # named accents
+ return $_;
+}
+
__END__