cache unicode character details in digraph include
[sheet.git] / rfc1345convert
index c1b3861aa65dc77137bba89a191723dd28a15279..8b29b8048b821846b23a9886f22beb3a49754a66 100644 (file)
@@ -46,9 +46,20 @@ for (@t) {
        $di{$mnem} = hex $char;
 }
 
+# optionally get unicode character information
+my %charinfo = eval {
+       require Unicode::UCD;
+       map { $_ => Unicode::UCD::charinfo($di{$_}) } keys %di;
+};
+
 # output perl code of hash
 # (assume no backslashes or curlies, so we can just q{} w/o escaping)
 print "{\n";
-print "q{$_}=>$di{$_},\n" for sort keys %di;
+printf "q{%s}=>[%s],\n", $_, join(',',
+       $di{$_},       # glyph code point
+       $charinfo{$_}  # optional additional arguments
+               ? map {"'$_'"} @{ $charinfo{$_} }{qw/name category script/}
+               : ()
+) for sort keys %di;
 print "}\n";