Programs that deal with characters and strings often need to perform tests that "classify a character." Is the character a letter? A digit? A whitespace character? and so forth.
Module CharClass provides a set of boolean function procedures that are used for such classification of values of the type CHAR. All procedures accept a single argument of type CHAR and return a BOOLEAN result.
Recall that Oberon-2 is defined so that characters are ordered in the same manner as defined by ASCII. Specifically, all the digits precede all the upper-case letters, and all the upper-case letters precede all the lower-case letters. This assumption is carried over into module CharClass. Also, note that CharClass uses constants defined in module Ascii within many of its procedures (see section Module Ascii)
For example, the function IsLetter is used to test whether a particular character is one of `A' through `Z' or `a' through `z':
Out.String("The character '"); IF CharClass.IsLetter(c) THEN Out.Char(c); Out.String("' is a letter."); ELSE Out.Char(c); Out.String("' isn't a letter."); END; Out.Ln
Please note: None of these predicates are affected by the current localization setting. For example, IsUpper will always test for "A"<=ch & ch<="Z" regardless of whether the locale specifies that additional characters belong to this set or not. The same holds for the compare and capitalization procedures in module Strings.
The implementation-defined character used to represent end-of-line internally by OOC (see section Module Ascii)
Read-only Variable: systemEol
An implementation defined string that represents the end-of-line marker used by the target system for text files. systemEol may be more than one character in length, and is not necessarily equal to eol. Note that systemEol is a string; it is always terminated by 0X (i.e., systemEol cannot contain the character `0X').
Function: IsNumeric (ch: CHAR): BOOLEAN
Returns TRUE if, and only if, ch is classified as a numeric character (i.e., a decimal digit---`0' through `9').
Function: IsLetter (ch: CHAR): BOOLEAN
Returns TRUE if, and only if, ch is classified as a letter.
Function: IsUpper (ch: CHAR): BOOLEAN
Returns TRUE if, and only if, ch is classified as an upper-case letter.
Function: IsLower (ch: CHAR): BOOLEAN
Returns TRUE if, and only if, ch is classified as a lower-case letter.
Function: IsControl (ch: CHAR): BOOLEAN
Returns TRUE if, and only if, ch represents a control function (that is, an ASCII character that is not a printing character).
Function: IsWhiteSpace (ch: CHAR): BOOLEAN
Returns TRUE if, and only if, ch represents a space character or other "format effector". IsWhiteSpace returns TRUE for only these characters:
` ' -- space (i.e., `Ascii.sp')
`Ascii.ff' -- formfeed
`Ascii.cr' -- carriage return
`Ascii.ht' -- horizontal tab
`Ascii.vt' -- vertical tab
Function: IsEOL (ch: CHAR): BOOLEAN
Returns TRUE if, and only if, ch is the implementation-defined character used to represent end of line internally.