7 use open OUT => ':utf8', ':std';
10 our $VERSION = '1.03';
12 # create a hash of desired input
13 my $di = do 'data/digraphs-rfc.inc.pl'
14 or die "error reading digraphs include: ", $@ // $!;
17 my $extra = do 'data/digraphs-shiar.inc.pl'
18 or warn "could not include shiar proposals: ", $@ // $!;
19 my $vim = do 'data/digraphs-vim.inc.pl'
20 or warn "could not include vim extensions ", $@ // $!;
21 $di = { %{$vim // {}}, %{$di}, %{$extra // {}} };
23 # optionally get unicode character information
24 my $uninfo = do 'unicode-char.inc.pl'
25 or warn "could not include unicode details: ", $@ // $!;
27 # convert info hashes into arrays of strings to output in display order
28 for my $row (values %{$uninfo}) {
29 my ($class, $name, $di, $html, $string) = @{$row};
30 $row = [$name, $class];
31 push @{$row}, '', $string if defined $string;
34 # output perl code of hash
35 # (assume no backslashes or curlies, so we can just q{} w/o escaping)
36 print "# automatically generated by $0\n";
39 printf '(map {$_=>0} qw{%s}),'."\n", join(' ',
40 grep { !defined $di->{$_} }
41 map { substr($_, 1, 1).substr($_, 0, 1) } sort keys %{$di}
43 printf "q{%s}=>[%s],\n", $_, join(',',
44 $di->{$_}, # original code point
45 (map {"'$_'"} @{ $uninfo->{ chr $di->{$_} } // [] }), # optional additional arguments
46 ) for sort keys %{$di};
53 mkdigraphlist - Output character list of combined digraph data
57 mkdigraphlist >digraphs.inc.pl
58 perl -e'$di = do "digraphs.inc.pl"; print chr $di->{DO}->[0]'
62 Parses the official RFC-1345 document, searching the
63 'character mnemonic table' for all digraph definitions.
64 If successful, Perl code is output resulting in a hash
65 with character data keyed by digraph.
66 Any errors and warnings are given at STDERR.
68 The value can either be a scalar string containing another
69 digraph which can be considered identical (usually inverted),
70 or an array ref containing at least the resulting character's
71 Unicode code point value. If available, the following UCD data
72 is appended: character name, category, script, and output string.
76 AE => [198, 'LATIN CAPITAL LETTER AE', 'Lu Xl', 'Latin'],
82 Mischa POSLAWSKY <perl@shiar.org>
86 Licensed under the GNU Affero General Public License version 3.