aboutsummaryrefslogtreecommitdiff
path: root/a8utf8
diff options
context:
space:
mode:
Diffstat (limited to 'a8utf8')
-rwxr-xr-xa8utf811
1 files changed, 10 insertions, 1 deletions
diff --git a/a8utf8 b/a8utf8
index f5f2df7..0cca2ac 100755
--- a/a8utf8
+++ b/a8utf8
@@ -121,6 +121,7 @@ while(@ARGV && $ARGV[0] =~ /^-/) {
for($ARGV[0]) {
/^-i$/ && do { $table = \%xl_intl_table; next; };
/^-t$/ && do { $print_table = 1; next; };
+ /^-r$/ && do { $reverse = 1; next; };
/^--?h/ && do { usage(0) };
warn "$SELF: unknown option: $_\n";
usage(1);
@@ -128,6 +129,14 @@ while(@ARGV && $ARGV[0] =~ /^-/) {
shift @ARGV;
}
+if($reverse) {
+ binmode(STDOUT, ":bytes");
+ for(keys %$table) {
+ $revtable{ord($table->{$_})} = chr($_);
+ }
+ $table = \%revtable;
+}
+
if($print_table) {
for(sort { $a <=> $b } keys %$table) {
my $chr = translate(chr $_);
@@ -156,7 +165,7 @@ sub translate {
sub usage {
print <<EOF;
-Usage: $SELF [--help] | [-t [-i]] | [-i] infile [infile ...]
+Usage: $SELF [--help] | [-t [-r] [-i]] | [-r] [-i] infile [infile ...]
See man page for details.
EOF
exit $_[0];