#!/usr/bin/perl -w
#
# __copy1__
# __copy2__
#
my $CMD		= "ascii";
my $CMDVER	= "1.1";
my $CMDSTR	= "$CMD v$CMDVER (2026-08-16)";

my $cnt		= -1;
my $format	= "%3d";
my $f_all	= 0;
my $f_terse	= 0;

while (@ARGV) {
	$_ = shift( @ARGV );
	CASE: {
		if ($_ eq '-a' || $_ eq '--all')	{ $f_all = 1; last CASE; }
		if ($_ eq '-o' || $_ eq '--octal')	{ $format = "%03o"; last CASE; }
		if ($_ eq '-t' || $_ eq '--terst')	{ $f_terse = 1; last CASE; }
		usage();
	}
}

$format	= "$format %c  ";

if ($f_terse) {
	usage()		if (!$f_all);
}

if ($f_all) {
	for $_ (33 ... 255)
	{
		# 127 ... 160 range not printable
		#
		if ($_ == 127) {
			print( "\n" )	if (!$f_terse);
			$cnt = -1;
			next;
		}
		next		if ($_ >= 127 && $_ <= 160);

		# breaks every 10 entries
		#
		if ($f_terse) {
			printf( "%c ", $_ );
		} else {
			print( "\n" )	if (!(++$cnt % 10));
			printf( $format, $_, $_ );
		}
	}
} else {
	print( "\n" );
	printgroup( (224, 232, 236, 242, 249) );
	print( "\n" );
	printgroup( (192, 200, 205, 210, 217) );
}

print( "\n" );
print( "\n" )	if (!$f_terse);
exit( 0 );

sub printgroup
{
	for $_ (@_) {
		printf( $format, $_, $_ );
	}
	print( "\n" );
	for $_ (@_) {
		printf( $format, $_ + 1, $_ + 1 );
	}
	1;
}



sub usage
{
	printf( STDERR "
== $CMDSTR == show printable ascii chars ==

usage: $CMD [options]

options:
  -o|--octal	prints octal values instead of decimal
  -a|--all	prints all chars (default: only accented vocals)
  -t|--terse	just prints chars in one line (works only with --all)
\n" );
	exit( 1 );
}
