X-Git-Url: http://git.shiar.nl/sheet.git/blobdiff_plain/a9bd14706592fd50c5e427635d6c70005dfa4953..b8cac6e3a9b47f1a2ae9dfc7bfc53df8fec1d004:/rfc1345convert diff --git a/rfc1345convert b/rfc1345convert index 6edfa74..d33377f 100644 --- a/rfc1345convert +++ b/rfc1345convert @@ -46,10 +46,26 @@ for (@t) { $di{$mnem} = hex $char; } +# personal addendums +my @extra; +if (-r 'shiar.inc.txt') { + open my $include, '<:utf8', 'shiar.inc.txt'; + for (readline $include) { + m{^([!"%'-Z_a-z]{2}) (.)} or next; + warn("$1 already defined"), next if defined $di{$1}; + $di{$1} = ord $2; + push @extra, $1; + } +} +warn $@ if $@; + # optionally get unicode character information my %info = eval { require Unicode::UCD; - map { $_ => Unicode::UCD::charinfo($di{$_}) } keys %di; + map { + $_ => Unicode::UCD::charinfo($di{$_}) + || { block => '?', category => 'Xn', name => '', script => '' } + } keys %di; }; # add custom categories for certain blocks @@ -58,6 +74,20 @@ for (values %info) { $_->{category} .= ' Xl' if $_->{block} eq 'Latin-1 Supplement'; } +# 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('', $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) print "{\n";