9.8 CharacterΒΆ

The members of the domain Character are values representing letters, numerals and other text elements. For more information on related topics, see CharacterClassXmpPage and StringXmpPage .

Characters can be obtained using String notation.

chars := [char "a", char "A", char "X", char "8", char "+"]
\[\]
[a,A,X,8,+]

Type: List Character

Certain characters are available by name. This is the blank character.

space()
\[\]
 

Type: Character

This is the quote that is used in strings.

quote()
\[\]

Type: Character

This is the escape character that allows quotes and other characters within strings.

escape()
\[\]

Type: Character

Characters are represented as integers in a machine-dependent way. The integer value can be obtained using the ordordCharacter operation. It is always true that char(ord c) = c and ord(char i) = i, provided that i is in the range 0..size()$Character-1.

[ord c for c in chars]
\[\]
[97,65,88,56,43]

Type: List Integer

The lowerCaselowerCaseCharacter operation converts an upper case letter to the corresponding lower case letter. If the argument is not an upper case letter, then it is returned unchanged.

[upperCase c for c in chars]
\[\]
[A,A,X,8,+]

Type: List Character

Likewise, the upperCaseupperCaseCharacter operation converts lower case letters to upper case.

[lowerCase c for c in chars]
\[\]
[a,a,x,8,+]

Type: List Character

A number of tests are available to determine whether characters belong to certain families.

[alphabetic? c for c in chars]
\[\]
[true,true,true,false,false]

Type: List Boolean

[upperCase? c for c in chars]
\[\]
[false,true,true,false,false]

Type: List Boolean

[lowerCase? c for c in chars]
\[\]
[true,false,false,false,false]

Type: List Boolean

[digit? c for c in chars]
\[\]
[false,false,false,true,false]

Type: List Boolean

[hexDigit? c for c in chars]
\[\]
[true,true,false,true,false]

Type: List Boolean

[alphanumeric? c for c in chars]
\[\]
[true,true,true,true,false]

Type: List Boolean