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 $di = { %{$di}, %{$extra // {}} };
21 # optionally get unicode character information
22 my $uninfo = do 'unicode-char.inc.pl'
23 or warn "could not include unicode details: ", $@ // $!;
25 # convert info hashes into arrays of strings to output in display order
26 for my $row (values %{$uninfo}) {
27 my ($class, $name, $di, $html, $string) = @{$row};
28 $row = [$name, $class];
29 push @{$row}, '', $string if defined $string;
32 # output perl code of hash
33 # (assume no backslashes or curlies, so we can just q{} w/o escaping)
34 print "# automatically generated by $0\n";
37 printf '(map {$_=>0} qw{%s}),'."\n", join(' ',
38 map { substr($_, 1, 1).substr($_, 0, 1) } sort keys %{$di}
40 printf "q{%s}=>[%s],\n", $_, join(',',
41 $di->{$_}, # original code point
42 (map {"'$_'"} @{ $uninfo->{ chr $di->{$_} } // [] }), # optional additional arguments
43 ) for sort keys %{$di};
50 mkdigraphlist - Output character list of combined digraph data
54 mkdigraphlist >digraphs.inc.pl
55 perl -e'$di = do "digraphs.inc.pl"; print chr $di->{DO}->[0]'
59 Parses the official RFC-1345 document, searching the
60 'character mnemonic table' for all digraph definitions.
61 If successful, Perl code is output resulting in a hash
62 with character data keyed by digraph.
63 Any errors and warnings are given at STDERR.
65 The value can either be a scalar string containing another
66 digraph which can be considered identical (usually inverted),
67 or an array ref containing at least the resulting character's
68 Unicode code point value. If available, the following UCD data
69 is appended: character name, category, script, and output string.
73 AE => [198, 'LATIN CAPITAL LETTER AE', 'Lu Xl', 'Latin'],
79 Mischa POSLAWSKY <perl@shiar.org>
83 Licensed under the GNU Affero General Public License version 3.