[<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
Char                     Single Characters                       Ordinal Type

    The data type Char represents single characters. Character values are
    represented by surrounding the character desired with single quotes;
    thus, the capital letter A is 'A', a question mark is '?', and so on.

    Standard Pascal does not define the specifics of character values
    beyond three relationships: The digits '0' through '9' must be
    numerically ordered and contiguous; the uppercase letters 'A' through
    'Z' must be alphabetically ordered; and the lowercase letter 'a'
    through 'z' must be alphabetically ordered.

    The underlying value of a character is given by the function Ord(Ch).
    The character represented by a given integer value is given by the
    function Chr(I). Thus Ch = Chr(Ord(Ch)).

    Characters in Turbo Pascal are based on the ASCII character set, which
    easily meets the requirements above. Each character occupies one byte,
    whose value is the ASCII code of the character it represents (see the
    ASCII table). Standard ASCII codes are defined for the values 0..127.
    The IBM PC and compatibles use the codes 128..255 for special letters
    and drawing characters.

    Turbo Pascal allows two alternative notations for character values.
    Those characters with ASCII codes in the range 0..31 are known as
    control codes, and are referred to by using the names of the
    characters in the range 64..95; thus Chr(0) is Ctrl-@, Chr(1) is Ctrl-
    A, Chr(2) is Ctrl-B, and so on. Control characters can be represented
    in Turbo Pascal by  a caret (^) followed by the corresponding letter:
    ^@, ^A, ^B, and so on.

    In addition, any character can be represented by a number sign (#)
    followed by the ASCII code: #0, #65, #214. This is a shorthand
    notation for Chr(0), Chr(65), and Chr(214).

  -------------------------------- Example ---------------------------------

           var
             Iota,Able,Fred : Char;

           begin
             Iota := 'i';           { Iota gets 'i' }
             Able := #207;          { Able gets '-' }
             Fred := ^D;            { Fred gets Ctrl-D, which is #4 }
           end.

See Also: strings
This page created by ng2html v1.05, the Norton guide to HTML conversion utility. Written by Dave Pearson