Char



next up previous contents index
Next: String Up: No Title Previous: Real

Char

Type "char" contains the ASCII characters. Its objects are immutable. "Char" literals are enclosed in single quotes. Printing ASCII characters (octal 40 through octal 176), other than single quote or backslash, can be written as that character enclosed in single quotes. Any character can be written by enclosing one of the following escape sequences in single quotes:
escape sequence    character
\tex{\sf\bs\sq}    single quote
\tex{\sf\bs\dq}    double quote
\\                  backslash
\t                 horizontal tab
\v                 vertical tab
\n                 newline character
\r                 carriage \tex{return}
\f                 form feed (or new page)
\b                 backspace
\\ tex{\em ddd}     octal value (specified by exactly three octal digits)
If the octal value specified in the "ddd" form does not correspond to a legal ASCII value, there will be a compile-time error. Examples of character literals are
'', '7', 'a', '"', '\"', '\'', '\n', '\000'

Methods for type "char"

  to_int ( ) returns (int)
      % effects   returns the integer ASCII code for self.

  to_string ( ) returns (string)
      % effects   returns a one character string containing self.

  lt (c: char) returns (bool)
  le (c: char) returns (bool)
  ge (c: char) returns (bool)
  gt (c: char) returns (bool)
      % effects   these orderings are consistent with the ASCII numbering of chars.

  equal (c: char) returns (bool)
      % effects   returns true if and only if self is same as c

  similar (c: char) returns (bool)
      % effects   returns true if and only if self is same as c

  copy ( ) returns (char)
      % effects   returns self

  unparse ( ) returns (string)
      % effects   If self is a printable character, then returns a one character string
      %           containing self.  Else returns a string containing an escape sequence
      %           that represents self.



theta-questions@lcs.mit.edu