Characters script

Inspired by Simon Cozens’ secret software idea, here’s a script in my ~/bin dir that I use often. It prints all the glyphs and decimal equivalents for ASCII and any other UTF8 range you specify. I find it especially useful for writing XML/HTML when I want to specify a numerical entity value.

#!/usr/bin/perl # # Copyright 2005 perl@peknet.com # Released under the Free Beer License # # # print chart of chars and matching nums # just latin1 by default # otherwise, specify start/stop numerals at cmd line # # NOTE the ANSI color stuff is unused

use strict; use warnings; use Term::ANSIColor; binmode STDOUT, ‘:utf8’; print ‘ ‘; my $on = color(‘bold’); my $off = color(‘reset’); my $c = 0; my $start = shift @ARGV || 161; my $stop = shift @ARGV || 255; for (33 .. 126, $start .. $stop) { my $n = $_; if ($_ < 100) { $n = ” $n”; } print(“$n “, chr($_), ‘ ‘); if (++$c == 6) { print “\n “; $c = 0; } } print “\n”;

Leave a Reply