5 use open IO => ':encoding(utf-8)', ':std';
10 # translation table for deprecated code points
13 0xF016 => '⇧', # shift
14 0xF017 => '⎈', # control
17 # expect input data source at command line
18 @ARGV or die "Specify input source file or - for STDIN\n";
20 # convert each character line to perl code
21 # (assume no backslashes or curlies, so we can just q{} w/o escaping)
22 say "# automatically generated by $0";
25 while ($_ = readline) {
26 my ($chrhex, $mnems, $sample, $name) = m{\A([0-9A-F ]{5}) (.{11}) (.)\h(.*)}i
27 or warn("syntax error on line $.: $_"), next;
29 my $chrnum = hex $chrhex;
30 my $chr = chr $chrnum;
32 or warn("character mismatch on line $.: $_"), next;
33 $chr = $replace{$chrnum} or next if defined $replace{$chrnum};
34 my $chrstr = pp($replace{$chrnum} // $chr);
35 for my $mnem (split / /, $mnems) {
36 # next if length $mnem != 2;
37 say "q{$mnem} => $chrstr, # $name";
46 mkdigraphs-plan9 - Output digraph data from Plan9 keyboard data
50 Extract digraphs from text specifications as a perl hash:
52 mkdigraphs-plan9 keyboard >digraphs-plan9.inc.pl
54 Input can be the literal RFC (or similar) document:
56 curl https://9fans.github.io/usr/local/plan9/lib/keyboard | mkdigraphs-plan9 -
58 Test by printing the character for DO (should be a dollar sign):
60 perl -e'$di = do "digraphs-plan9.inc.pl"; print chr $di->{DO}'
64 Parses the official RFC-1345 document, searching the
65 'character mnemonic table' for all digraph definitions.
66 If successful, Perl code is output resulting in a hash
67 with Unicode code points keyed by digraph.
68 Obsolete values (references to private use area)
69 are converted to modern alternatives.
70 Any errors and warnings are given at STDERR.
74 Mischa POSLAWSKY <perl@shiar.org>
78 Licensed under the GNU Affero General Public License version 3.