Please consider a donation to the Higher Intellect project. See or the Donate to Higher Intellect page for more info.

ASCII control codes

From Higher Intellect Vintage Wiki
Jump to navigation Jump to search
To understand the original intent of the ASCII control codes, you have
to think of teletypes, using paper tape, configured in a multidrop
system with relay logic used to turn on or off individual teletypes in
the bunch, and you have to remember that the designers were pretty
smart and they anticipated future developments, but they also managed
to include provisions for things that never happened.  Here are the
ASCII control characters, and a few others, with comments on how they
were supposed to be used and how this relates to current popular uses:


  NULL	00 ^@	always ignored -- leader and trailer on paper tape
		systems was typically made of sequences of NULLs.

  SOH	01 ^A	start of heading -- imagine a heading containing, for
		example, the address of the recipient.  You could have
		relay logic that scans for SOH, then enables the print
		mechanism if the following character matches this
		station's address.  In early documentation, this was
		called start of message.

  STX	02 ^B	start of text -- if the heading matched, start printing
		with the following character.  In early documentation,
		this was called end of address.

  ETX	03 ^C	end of text -- now is a good time to stop printing.
		Your message might continue after this with a checksum
		or other administrative stuff.  In early documentation,
		this was called end of message.  The common use of
		control C as a kill character stems from this -- it
		indicates the end of your text addressed to some

  EOT	04 ^D	end of transmission -- relay logic could decode this
		and, if there is a tape in the tape reader, it could
		begin transmitting its own message.

  ENQ	05 ^E	enquire -- on receiving this, local relay logic would
		generate a response.  In early documentation, this was
		called WRU or who are you.  Teletypes had programmable
		response sequences that were encoded on a music box
		mechanism, and it was up to the customer to break
		plastic fingers off the drum to code how it responded
		to an ENQ.

  ACK	06 ^F	acknowledge -- one possible response to ENQ.  In early
		documentation, this was called RU or are you.

  BEL	07 ^G	bell -- ring the bell in the terminal.  Teletypes had
		real bells where most modern terminals have beepers of
		some kind.  A sequence of BEL characters sent to a
		teletype sounded very much like a telephone ringing.

  BS	08 ^H	backspace.

  HT	09 ^I	horizontal tab.

  LF	0A ^J	linefeed.

  VT	0B ^K	vertical tab.

  FF	0C ^L	formfeed -- page eject.

  CR	0D ^M	carrage return -- on many mechanical devices, CR was
		slow.  The sequence CR LF was always sent in that order
		so that the linefeed could be handled while the carriage
		was returning; a well adjusted Teletype could just finish
		the CR in this time (0.2 seconds), and a common sign that
		it was time to call the service man was that the first
		letter printed after a CR LF was printed "on the fly" on
		the way back to the margin.

  SO	0E ^N	shift out -- if you've got a two-color ribbon, shift to
		the alternate color, usually red.  There are obvious
		extensions of this to alternate character sets.

  SI	0F ^O	shift in -- undo whatever SO does.  For mysterious reasons
		that have no apparent connection to old or modern ASCII
		standards, DEC liked to use control O as a break character
		to suppress teletype output.

  DLE	10 ^P	data link escape -- an escape character is generally a
		prefix for something else.  DLE was expected to be used
		as a prefix on characters in the user data stream that
		might otherwise be interpreted as data link control
		characters, for example, flow control characters.  In
		some early documentation, this was called DC0 or device
		control zero.

  DC1	11 ^Q	device control 1 -- turn on the paper tape reader.
		In early documentation, this was called XON.

  DC2	12 ^R	device control 2 -- turn on the paper tape punch.

  DC3	13 ^S	device control 3 -- turn off the paper tape reader.
		In early documentation, this was called XOFF, The use
		of XON/XOFF (DC1/DC3) for flow control stems from their
		use to control the flow of data from the paper tape
		reader attached to a Teletype.

  DC4	14 ^T	device control 4 -- turn off the paper tape punch.

  NAK	15 ^U	negative acknowledge -- another possible response to ENQ.
		One flow control mechanism is to use ENQ to ask if the
		receiver has buffer space, and require the receiver to
		respond with either ACK (yes) or NAK (no).  ENQ could
		also be used to enquire about whether a retransmission
		is required after sending a checksum.  The popular use of
		control U to delete the current input line is only vaguely
		grounded in this definition.

  SYN	16 ^V	synchronous idle -- if you're using a synchronous
		transmission protocol, and you have no data to send, you
		send SYN characters to keep the clocks synchronized.
		The receiver should ignore these, and the transmitter may
		have to insert them into the data stream once in a while.

  ETB	17 ^W	end of transmission block -- used when a transmission must
		be broken into many blocks for some reason, for example,
		to place a checksum after each block.  Early documentation
		called this logical end of media.

  CAN	18 ^X	cancel -- take that back, what I just sent you is a
		mistake, ignore it.

  EM	19 ^Y	end of medium -- there's nothing left on this reel of
		(paper) tape.

  SUB	1A ^Z	substitute -- the next character is from an alternate
		character set.  SUB X might be equivalent to SO X SI,
		or it might be an alternate mechanism for extending the
		character set.  The common use of control Z as an end
		of file character has no obvious relation to the standard.

  ESC	1B ^[	escape -- the next character is to be interpreted as
		something other than text, for example, it might be an
		extended control character of some kind.

  FS	1C ^\	file separator -- useful if you have multiple logical
		files in one transmission.

  GS	1D ^]	group separator -- useful if files are made of groups
		of records.

  RS	1E ^^	record separator -- COBOL anyone?

  US	1F ^_	unit separator -- are records made of units?

  ALT	7D }	Some early teletypes had an ALT MODE key that generated
		this code instead of ESC.  This was interpreted as an
		escape code, which was no problem when nobody had lower
		case printers, but with the advent of full 96 character
		ASCII, there were obvious compatability problems.

  PRE	7E ~    A few terminals had a PREFIX key that generated this code
		instead of ALT MODE, with all the same problems.

  DEL	7F	delete -- remember, paper tape uses a hole to record each
		one and no hole to record each zero.  DEL is all holes,
		so it can be punched over any other character to rub it
		out (on old teletypes, it was the RUB or RUB OUT key).
		If you mispunch a character, just back up the tape and
		overpunch it with a DEL.  Software is expected to ignore
		DEL the same way it ignores NULL.