7 use open OUT => ':utf8', ':std';
11 # import and combine various digraph data
13 my $rfc = do 'digraphs-rfc.inc.pl'
14 or die "error reading digraphs include: ", $@ // $!;
15 my $extra = do 'digraphs-shiar.inc.pl'
16 or warn "could not include shiar proposals: ", $@ // $!;
17 my $vim = do 'digraphs-vim.inc.pl'
18 or warn "could not include vim extensions ", $@ // $!;
19 my $vimold = do 'digraphs-vim-74.inc.pl'
20 or warn "could not include vim compatibility ", $@ // $!;
21 my $di = { %{$vim // {}}, %{$rfc}, %{$extra // {}} };
23 # optionally get unicode character information
24 my $uninfo = do 'unicode-char.inc.pl'
25 or warn "could not include unicode details: ", $@ // $!;
27 # output perl code of hash
28 # (assume no backslashes or curlies, so we can just q{} w/o escaping)
29 print "# automatically generated by $0\n";
32 printf '(map {$_=>0} qw{%s}),'."\n", join(' ',
33 grep { !defined $di->{$_} }
34 map { substr($_, 1, 1).substr($_, 0, 1) } sort keys %{$di}
36 printf "q{%s}=>[%s],\n", s/(?=[\\}])/\\/gr, join(',',
37 ord $di->{$_}, # original code point
39 $uninfo->{ $di->{$_} }->[1] // '', # name
42 ? $vim->{$_} ? 'l4' : 'l1' # vim+rfc or rfc only
43 : $vim->{$_} ? 'l3' : 'l2', # vim only or neither
44 $vimold && $vim->{$_} && !$vimold->{$_} ? 'ex' : (), # new vim feature
46 ($uninfo->{ $di->{$_} }->[0] // '') =~ s/ u-di| u-prop| ex//gr, # class
47 $uninfo->{ $di->{$_} }->[4] // (), # string
48 ) for sort keys %{$di};
55 mkdigraphlist - Output character list of combined digraph data
59 mkdigraphlist >digraphs.inc.pl
60 perl -e'$di = do "digraphs.inc.pl"; print chr $di->{DO}->[0]'
64 Combines precompiled digraph includes of rfc (1345), vim, and shiar
65 and outputs a complete map including character details and usage classes.
67 The value can either be a scalar string containing another
68 digraph which can be considered identical (usually inverted),
69 or an array ref containing at least the resulting character's
70 Unicode code point value. If available, the following UCD data
71 is appended: character name, usage classes, unicode classes,
72 and replacement output string.
76 AE => [198, 'LATIN CAPITAL LETTER AE', 'u-di', 'Latin Lu Xl u-v11'],
82 Mischa POSLAWSKY <perl@shiar.org>
86 Licensed under the GNU Affero General Public License version 3.