[Skip Navigation] [Remove Frame] [CS320] [Text Version] comp.ascii.html Sat Dec 23 07:59:34 PST 2006

Contents


    ASCII -- The American Standard Code for Information Interchange

      Introduction

      The ASCII code includes control characters that do not print a character. These have a short standard name, a standard function plus a large number of non-standard applications.

      The original code was developed in the days of mechanical terminals such as Teletypes. The meaning of the control codes are defined in terms of typewriter like actions - Tab, ring bell, back-space, return, and line feed. These have been re-interpreted as cursor movements for CRT's. Many computer systems use the control codes for special purposes. A competent software engineer will know about the control codes; what they were designed to mean, and how they are used or mis-used in real systems.

      In many high level languages the ASCII characters are representable as a function, (eg Pascal - chr(i), C - (char)i, or Ada - CHAR'VAL(i) ) where "i" is an integer. Ada specifies a special standard package that defines ASCII with standard names for constants representing the coded character. In C they can be indicated by a backslash character (\) followed by either a special letter, or as a hexadecimal or octal number. The following dictionary defines the ASCII name, its position in the ASCII code, its original meaning, and Ada 83 symbol.

      Control characters

    1. ASCII::=
      Net{
        There are 128 ASCII codes numbered from 0 to 128. I will use the notation of
        		character_nbr(i)
        to indicate the i'th ASCII character:
      1. character_nbr::0..127---char, -- The "---" indicates that there are precisely 128 standard characters that correspond, one-for-one, to their code numbers.

        I use the C/C++ abbreviation to indicate the set of all ASCII codes:

      2. char::=character_nbr(0..127), --all the ASCII codes.

      3. CTRL_CHARS::=
        Net{
        1. NUL::=character_nbr(0)::= Fills in time* (ASCII'NUL).
        2. SOH::=character_nbr(1)::= Start Of Header (routing info)(ASCII'SOH).
        3. STX::=character_nbr(2)::= Start Of Text (end of header)(ASCII'STX).
        4. ETX::=character_nbr(3)::= End Of Text(ASCII'ETX).
        5. EOT::=character_nbr(4)::= End Of Transmission(ASCII'EOT).
        6. ENQ::=character_nbr(5)::= ENQuiry, asking who is there(ASCII'ENQ).
        7. ACK::=character_nbr(6)::= Receiver ACKnowledges positively(ASCII'ACK).
        8. BEL::=character_nbr(7)::= Rings BELl or beeps(ASCII'BEL)\a.
        9. BS::=character_nbr(8)::= Move print head Back one Space(ASCII'BS)\b.
        10. HT::=character_nbr(9)::= Move to next Tab-stop(ASCII'HT)\t.
        11. LF::=character_nbr(10)::= Line Feed (ASCII'LF)\n.
        12. VT::=character_nbr(11)::= Vertical Tabulation(ASCII'VT)\v.
        13. FF::=character_nbr(12)::= Form Feed - new page or form(ASCII'FF)\f.
        14. CR::=character_nbr(13)::= Carriage Return to left margin(ASCII'CR)\r.
        15. SO::=character_nbr(14)::= Shift Out of ASCII(ASCII'SO).
        16. SI::=character_nbr(15)::= Shift into ASCII(ASCII'SI).
        17. DLE::=character_nbr(16)::= Data Link Escape(ASCII'DLE).
        18. DC1::=character_nbr(17)::= Device control(ASCII'DC1).
        19. DC2::=character_nbr(18)::= Device control(ASCII'DC2).
        20. DC3::=character_nbr(19)::= Device control(ASCII'DC3).
        21. DC4::=character_nbr(20)::= Device control(ASCII'DC4).
        22. NAK::=character_nbr(21)::= Negative Acknowledgment(ASCII'NAK).
        23. SYN::=character_nbr(22)::= Sent in place of data to keep systems synchronized(ASCII'SYN).
        24. ETB::=character_nbr(23)::= End of transmission block(ASCII'ETB).
        25. CAN::=character_nbr(24)::= Cancel previous data(ASCII'CAN).
        26. EM::=character_nbr(25)::= End of Medium(ASCII'EM).
        27. SUB::=character_nbr(26)::= Substitute(ASCII'SUB).
        28. ESC::=character_nbr(27)::= Escape to extended character set(ASCII'ESC).
        29. FS::=character_nbr(28)::= File separator(ASCII'FS).
        30. GS::=character_nbr(29)::= Group separator(ASCII'GS).
        31. RS::=character_nbr(30)::= Record separator(ASCII'RS).
        32. US::=character_nbr(31)::= Unit separator(ASCII'US).
        33. SP::=character_nbr(32)::= Blank Space character(ASCII'SP).

        34. DEL::=character_nbr(127)::=Punch out all bits on paper tape(delete).

        }=::CTRL_CHARS.

        Normal Characters

      4. OTHER_CHARS::=
        Net{
          The Ada standard defines a name for all printable characters. MATHS inherits these and adds some. Here are the standard MATHS names for the common characters in ASCII.

        1. exclam::=character_nbr(33)::="!".
        2. quotes::=character_nbr(34)::="\"".
        3. number::=hash.
        4. sharp::=hash.
        5. hash::=character_nbr(35)::="#".
        6. dollar::=character_nbr(36)::="$".
        7. per_cent::=character_nbr(37)::="%".
        8. ampersand::=character_nbr(38)::="&".
        9. apostrophe::=character_nbr(39)::="'".
        10. l_paren::=character_nbr(40)::="(".
        11. r_paren::=character_nbr(41)::=")".
        12. asterisk::=star.
        13. star::=character_nbr(42)::="*".
        14. plus::=character_nbr(43)::="+".
        15. comma::=character_nbr(44)::=",".
        16. minus::=character_nbr(45)::="-".
        17. dot::=character_nbr(46)::=".".
        18. divide::=slash.
        19. slash::=character_nbr(47)::="/".

        20. digits::=character_nbr(48)..character_nbr(57).

        21. colon::=character_nbr(58)::=":".
        22. semicolon::=character_nbr(59)::=";".
        23. less_than::=character_nbr(60)::="<".
        24. equal::=character_nbr(61)::="=".
        25. greater_than::=character_nbr(62)::=">".
        26. query::=character_nbr(63)::="?".
        27. at_sign::=character_nbr(64)::="@".

        28. upper_case_letters::=character_nbrs(65)..character_nbr(90).

        29. l_bracket::=character_nbr(91)::="[".
        30. backslash::=character_nbr(92)::="\".
        31. r_bracket::=character_nbr(93)::="]".
        32. circumflex::=character_nbr(94)::="^".
        33. underscore::=character_nbr(95)::="_".
        34. grave::=reverse_quote.
        35. reverse_quote::=character_nbr(96)::="`".

        36. lower_case_letters::=character_nbr(97)..character_nbr(121).

        37. l_brace::=character_nbr(123)::="{".
        38. bar::=character_nbr(124)::="|".
        39. r_brace::=character_nbr(125)::="}".
        40. tilde::=character_nbr(126)::="~".

          Charcter number 127 is the DEL control character.


        }=::OTHER_CHARS.

        Note

        Notice that NO ASCII character sends a BREAK signal. This is not a character. It is transmitted thru an RS232 cable by dropping the DTR line to the signal ground, or thru a modem by ceasing to send the carrier frequency for a fixed length of time. NUL transmits a character (with all bits=0), BREAK does not.

        Whitespace

      5. whitespace::= whitespace_char #(whitespace_char).
      6. whitespace_char::= SP | CR |LF | HT | ... .
      7. EOLN::=End Of Line string -- depends on the system you are using.
      8. |-EOLN ==> (CR | LF) #(CR | LF | HT | VT | ...).

        In COBOL and MATHS the "." character is both a punctuator and a decimal point. The following defines the cases when a "." is acting as a punctuator:

      9. period::="." whitespace,-- A dot followed by white space is treated as a period.

        Standard Character Sets

        char is the set of all ASCII characters.

      10. digit::="0".."9". See digits.
      11. letter::=upper_case_letter | llower_case_letter.
      12. upper_case_letter::="A".."Z". See upper_case_letters: characters 65..90.
      13. lower_case_letter::="a".."z". See lower_case_letters: characters 97..121.


      }=::ASCII.

      See Also

      Tables of ISO Latin 1 codes: [ symbol.html ]

      Notes on special uses of special characters


      1. The following have been used to mark the end of a string: NUL, ESC, 2 ESCs, grave accent, apostrophe, quotation, EOLN, slash.

      2. The following have been used to indicate the end of input: EOT, SUB, 2 CRs

      3. The following have been used to kill or delete the previous character: DEL, BS, #.

      4. The following have been used to cancel the current line of input: DEL, NAK(^U), hash(#)

      5. On a network the special character take on yet more meanings. For example, commonly RS232 communications use DC3(^S) and DC1(^Q) to delay and restart data transmission (originally to allow data to be punched). In an X.25 packet switched network SI(^O) forces the data through the intervening machines and DLE(^P) allows you to send commands to your local "Pad". Proprietary networks often have a special 'escape' character as well.

        The following can allow a following control character to appear in text: SYN(^V),


End