From 140ced429cba74084d65942840b1f97fc77d8d9b Mon Sep 17 00:00:00 2001 From: "B. Watson" Date: Tue, 23 Apr 2024 22:28:28 -0400 Subject: a8utf8: add -r (reverse) option. --- a8utf8 | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'a8utf8') 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 <