digraphs: mark reversed matches
[sheet.git] / rfc1345convert
index 412bac14cbbd7cc50afc017301d627f158733dbe..c5a3e80c9cec88d0c5f71ba8f4cd9c6469a333f1 100644 (file)
@@ -77,9 +77,23 @@ for (values %info) {
 # mark unofficial extras as such
 $info{$_}->{category} .= ' Xz' for @extra;
 
 # mark unofficial extras as such
 $info{$_}->{category} .= ' Xz' for @extra;
 
+for (keys %di) {
+       # find control characters (first 32 chars from 0 and 128)
+       next if $di{$_} & ~0b1001_1111;
+       # rename to something more descriptive
+       $info{$_}->{name} = $info{$_}->{unicode10}
+               ? '<'.$info{$_}->{unicode10}.'>'  # the old name was much more useful
+               : sprintf('<control U+%04X>', $di{$_});  # at least identify by value
+       # show descriptive symbols instead of control chars themselves
+       $di{$_} += 0x2400 if $di{$_} < 32;
+}
+
 # output perl code of hash
 # (assume no backslashes or curlies, so we can just q{} w/o escaping)
 # output perl code of hash
 # (assume no backslashes or curlies, so we can just q{} w/o escaping)
-print "{\n";
+print "+{\n";
+printf '(map {$_=>0} qw{%s}),'."\n", join(' ',
+       map { substr($_, 1, 1).substr($_, 0, 1) } sort keys %di
+);
 printf "q{%s}=>[%s],\n", $_, join(',',
        $di{$_},       # glyph code point
        $info{$_}  # optional additional arguments
 printf "q{%s}=>[%s],\n", $_, join(',',
        $di{$_},       # glyph code point
        $info{$_}  # optional additional arguments