-
Notifications
You must be signed in to change notification settings - Fork 1
/
chars
executable file
·47 lines (44 loc) · 960 Bytes
/
chars
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#!/usr/bin/perl
#
#
# print chart of chars and corresponding hexdump vals
# just latin1 by default
# otherwise, specify start/stop numerals at cmd line
#
use strict;
use warnings;
use Term::ANSIColor;
use charnames ();
binmode STDOUT, ':utf8';
my %escapes = (
"\a" => "\\a",
"\b" => "\\b",
"\f" => "\\f",
"\n" => "\\n",
"\r" => "\\r",
"\t" => "\\t",
"\x0B" => "\\v",
);
print ' ';
my $on = color('blue');
my $off = color('reset');
my $c = 0;
my $start = shift @ARGV || 161;
my $stop = shift @ARGV || 255;
for ( 33 .. 126, $start .. $stop ) {
my $safe = chr($_);
if ($_ < 33 && !$escapes{$safe}) {
$safe = charnames::viacode($_);
}
if ( $escapes{$safe} ) {
$safe = $escapes{$safe};
}
printf( "\\%05d $on%s$off \\x%05x ", $_, $safe, $_ );
$c = 3 if length($safe) > 2;
if ( ++$c == 4 ) {
print "\n ";
$c = 0;
}
}
print "\n";