in reply to Generating characters (0 to 255)
One Unix/Linux boxes, you can man ascii to print a table similar to those found in reference manuals.
Below is something I use to generate an ascii table when I'm not not on a *nix machine and don't have a book. It's pretty much the same as your code, just in the table format.
print "Decimal | Octal | Hex | Character\n"; print "--------+-------+-----+----------\n"; my @hs = (0 .. 9, 'A' .. 'F'); for my $r (@hs) { for my $c (@hs) { my $h = hex($r . $c); printf("%-8.8s\| %-6.6s\| %-4.4s\| %-s\n", sprintf("%u", $h), sprintf("%-3.3o", $h), sprintf("%-2.2X", $h), map({ s/\n/\^J/; $_ } sprintf("%c", $h))); } }
Update: Removed padding on last column per parv's suggestion below. Great idea!
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Re: Generating characters (0 to 255)
by tachyon (Chancellor) on Mar 28, 2003 at 00:23 UTC | |
by Aristotle (Chancellor) on Mar 30, 2003 at 21:27 UTC | |
Re: Re: Generating characters (0 to 255)
by parv (Parson) on Mar 27, 2003 at 21:12 UTC |