aboutsummaryrefslogtreecommitdiff
path: root/a8utf8
diff options
context:
space:
mode:
authorB. Watson <urchlay@slackware.uk>2024-04-23 22:28:28 -0400
committerB. Watson <urchlay@slackware.uk>2024-04-23 22:28:28 -0400
commit140ced429cba74084d65942840b1f97fc77d8d9b (patch)
tree94c26f67f46d4cffe6c3265dde192cfd7fc9ccba /a8utf8
parent046326dc430a15b675eff425ddd31d1ceb0fe916 (diff)
downloadbw-atari8-tools-140ced429cba74084d65942840b1f97fc77d8d9b.tar.gz
a8utf8: add -r (reverse) option.
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];