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