Sometimes the Mark I Eyeball is still the best tool. It is useful to be able to see problems with unprintable characters. The various line endings, old databases with now-uncommon delimiters, escape sequences of all kinds, strings like that all are peppered with unprintable ASCII characters. When problems arise, we need to see what's there. The usual solution is an eye-crossing hex dump with man ascii open in another terminal.

The old DEC VT-x terminals had a lovely solution. A terminal mode was available which printed ASCII control characters as single-character representations of their ASCII names. For instance tab, "\t", has the official name 'HT', for "Horizontal Tab". The DEC control font represents that as a miniature HT.

Moved by japhy's recent discussion, I was browsing the unicode character list. There amongst the math and the exotic languages, I found that DEC's control character set has a home at code point 2400, "Control Pictures". A light came on.

Here's a demo. I'll use HTML::Entities to make the result browser friendly.

#!/usr/bin/perl use strict; use warnings; use HTML::Entities; $_ = "\0foo\tbar\tbaz\r\n\a"; tr/\x00-\x1f\x7f/\x{2400}-\x{241f}\x{2421}/; print encode_entities $_; __END__ ␀foo␉bar␉baz␍␊␇
That's rendered by your browser as:
(assuming your unicode fonts have these characters). Of course this is much more interesting in a unicode-enabled terminal, but that is a whole different problem.

Added: graff, I don't recall seeing extended control characters on VT-100, either. The unicode list has those control characters themselves, with names like "START OF GUARDED AREA", "END OF GUARDED AREA", "STRING TERMINATOR", and the frightening "OPERATING SYSTEM COMMAND". I have seen no hint of Control Pictures for them.

More Added: There is room for extended control characters. The range of Control Pictures is 2400-243F, but only a few characters are assigned in the upper half of that range. They are 2420 ␠ (SPACE), 2421 ␡ (DELETE), 2422 ␢ (BLANK), 2423 ␣ (OPEN BOX), 2424 ␤ (NEWLINE), 2425 ␥ (DELETE FORM TWO), 2426 ␦ (SUBSTITUTE FORM TWO). The NEWLINE character would serve nicely for NEXT LINE. The rest don't seem to correspond. I suppose the unicode group would consider designs for the missing symbols. Who uses the extended control characters? Are they part of some standard, ISO-8859 maybe?

After Compline,

In reply to Printing the Unprintable by Zaxo

Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":

  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.