# 2025-06-21 - ITA-2 Telegraph Code
       
 (IMG) Western Union Bicycle Messengers (1911) (Smithsonian)
       
       A friend sent me a link to a video of someone creating art on an
       old-school mechanical typewriter.  Following up, i found typewriter
       art books [1] on the Internet Archive, one of which is dated 1936
       [2].
       
       I sent these links to another friend.  I called it an example of
       ASCII art from 1936.  This friend informed me that ASCII didn't
       exist in 1936.
       
       Doing a little research, i found that what existed in 1932 was
       ITA-2 telegraph code, which is encoded as 5-bit values that can be
       punched on 5-hole paper tape [3].  A perfect rabbithole to go down on
       this rainy day.  :-)
       
       I wrote a small AWK script to convert between ASCII and ITA-2.
       
       The first limitation i noticed was that ITA-2 cannot represent every
       ASCII character.  Like my keyboard, ITA-2 lacks lowercase letters.
       I wrote a small extension to work around this: any ASCII character
       that doesn't exist in ITA-2 would get encoded as a five character
       escape sequence.
       
       * FIGURES
       * ALLSPACE_NOTINUSE
       * Octal digit1
       * Octal digit2
       * Octal digit3
       
       Why octal?  Just for the fun of it.
       
       Below [4] is ita2.awk which converts between ASCII and ITA-2.
       
       Next i wrote an even smaller script to convert between ITA-2 and
       simulated paper tape.  Slackware's bsd-games package includes a `ppt`
       command that simulates 8-hole tape.  Below [5] is ppt5.awk, which
       simulates 5-hole tape.
       
       To get a "tape" version of the natural musical tones:
       
           $ printf ABCDEFG | mawk -f ita2.awk | mawk -f ppt5.awk >tones.txt
           $ pr -n -t tones.txt
               1   ________
               2   |   .oo|
               3   |oo . o|
               4   | oo.o |
               5   | o . o|
               6   |   . o|
               7   | oo. o|
               8   |oo .o |
               9   --------
       
       For the round trip:
       
           $ mawk -f ppt5.awk decode tones.txt | mawk -f ita2.awk decode
           ABCDEFG
       
       In xterm i can see a cat emoji using the following command.
       
           $ printf "\360\237\220\261" >cat.txt
           $ cat cat.txt
           🐱
       
       To get a "tape" encoding of that cat:
       
           $ mawk -f ita2.awk cat.txt | mawk -f ppt5.awk >tape.txt
           $ pr -2n -t tape.txt
               1   ________                       12   |oo .oo|
               2   |oo .oo|                       13   |   .  |
               3   |   .  |                       14   |o  .oo|
               4   |   . o|                       15   |o  .oo|
               5   |o o. o|                       16   |o o.o |
               6   |o o.o |                       17   |oo .oo|
               7   |oo .oo|                       18   |   .  |
               8   |   .  |                       19   |o  .oo|
               9   |o  .oo|                       20   |o o. o|
              10   |   . o|                       21   |o o.oo|
              11   |  o.oo|                       22   --------
       
       To send that cat on a round trip:
       
           $ mawk -f ppt5.awk decode tape.txt | mawk -f ita2.awk decode
           🐱
       
       To be silly, here's the paper tape with corresponding pohl code [6]:
       
               1   ________                       12   |oo .oo|   oddy-pod
               2   |oo .oo|   oddy-pod            13   |   .  |       pohl
               3   |   .  |       pohl            14   |o  .oo|  ahtah-pod
               4   |   . o|       poot            15   |o  .oo|  ahtah-pod
               5   |o o. o|  ahtah-tot            16   |o o.o |  ahtah-dye
               6   |o o.o |  ahtah-dye            17   |oo .oo|   oddy-pod
               7   |oo .oo|   oddy-pod            18   |   .  |       pohl
               8   |   .  |       pohl            19   |o  .oo|  ahtah-pod
               9   |o  .oo|  ahtah-pod            20   |o o. o|  ahtah-tot
              10   |   . o|       poot            21   |o o.oo|  ahtah-tee
              11   |  o.oo|        tee            22   --------
       
       For a sanity check, i found an photo of 5-hole tape [7] for CSIRAC,
       the first digital computer in Australia [8].
       
       I manually keyed in the first 10 characters visible in the photo.
       
           $ pr -n -t 5hole.txt
               1   ________
               2   |ooo. o|
               3   |ooo.o |
               4   |   .oo|
               5   |o o.oo|
               6   | o .  |
               7   |  o.  |
               8   | o .oo|
               9   |   .oo|
              10   |ooo.  |
              11   | o .  |
              12   --------
       
       Now to decode the virtual paper tape.
       
           $ mawk -f ppt5.awk decode 5hole.txt |\
               mawk -f ita2.awk decode         |\
               hexdump -C
           00000000  58 56 41 51 0d 20 4a 41  4d 0d    |XVAQ. JAM.|
           0000000a
       
       I guess this means it's working?  Apparently the lines of text end
       with CR only and no LF.
       
       p.s.
       
       To run these examples with mawk on DOS, you may need to set an
       environment variable MAWKBINMODE=1
       
       To run these examples with gawk, you may need to set an
       environment variable LC_ALL=C
       
       p.p.s.
       
       The predecessor to ITA-2 was Western Union telegraph code [11] [12].
       
       tags: history,nostalgia,retrocomputing,technical
       
       # Footnotes
       
 (HTM) [1] Art Typing (JS)
       
 (HTM) [2] How To Make "Typeys" (1936)
       
 (IMG) [3] ITA-2 alphabet on 5-hole tape
       
 (TXT) [4] ita2.awk
       
 (TXT) [5] ppt5.awk
       
 (DIR) [6] Pohl Code
       
 (IMG) [7] 5-hole tape photo
       
 (TXT) [8] CSIRAC (wikipedia)
       
 (HTM) [9] Computerphile Paper Tape Video
       
 (HTM) [10] DIY Paper Tape Puncher
       
 (IMG) [11] Western Union telegraph code table
       
 (HTM) [12] Codes of the World
       
 (TXT) [13] 92 Code (wikipedia)
       
 (TXT) [14] Brevity Code (wikipedia)
       
 (TXT) [15] Morse Code Abbreviations (wikipedia)
       
       # Tags
       
 (DIR) history
 (DIR) nostalgia
 (DIR) retrocomputing
 (DIR) technical