make rules for unicode-char.inc.pl and ttfsupport/
[sheet.git] / rfc1345convert
index f6f0ab8a2f88a5230fa2e6f2ee127143a3423ec3..4fd3940d011a212a2a53c0b7eb600ff22de74573 100755 (executable)
@@ -2,7 +2,9 @@
 
 use strict;
 use warnings;
+use utf8;
 
+use open OUT => ':utf8', ':std';
 use Data::Dumper;
 
 our $VERSION = '1.01';
@@ -108,7 +110,7 @@ my @extra;
 if (-r 'shiar.inc.txt') {
        open my $include, '<:utf8', 'shiar.inc.txt';
        for (readline $include) {
-               m{^([!"%'-Z_a-z]{2}) (.)} or next;
+               m{^(\$?[!"%'-Z_a-z]{2}) (.)} or next;
                warn("$1 already defined"), next if defined $di{$1};
                $di{$1} = ord $2;
                push @extra, $1;
@@ -116,6 +118,9 @@ if (-r 'shiar.inc.txt') {
 }
 warn $@ if $@;
 
+$di{chr $_} = $_ for 32 .. 126;
+$di{'\\'.$_} = delete $di{$_} for '{', '}', '\\';
+
 # optionally get unicode character information
 my %info = eval {
        require Unicode::UCD;
@@ -145,6 +150,10 @@ for (keys %di) {
        # show descriptive symbols instead of control chars themselves
        $info{$_}->{string} = $di{$_} < 32 ? chr($di{$_} + 0x2400) : chr(0xFFFD);
 }
+# presentational string for some control(lish) entries
+$info{$_}->{string} = '-' for grep { $di{$_} == 0x00AD } keys %di;
+$info{$_}->{string} = '→' for grep { $di{$_} == 0x200E } keys %di;
+$info{$_}->{string} = '←' for grep { $di{$_} == 0x200F } keys %di;
 
 # convert info hashes into arrays of strings to output in display order
 for my $row (values %info) {