4.3 The Char acter Type 59
4.3 The Character Type
The character type is the collection of all UTF-32 values as defined in the
Unicode Standard, Version 3.2 along with operations defined in Table 4.8. The ord
and char functions move between the character values and the natural numbers.
The ord function accepts a character value and specifies its associated Unicode
value. The char function is its inverse, taking a Unicode value and specifying its asso-
ciated Unicode value. For example:
char(ord(c::character)) == c::character
ord(’a’) == 16\0061\
ord(’U+2132’) == 16\2132\
The uc and dc functions change a character’s case to upper or lower case, respectively,
when such a conversion is defined. When the upper and lower case distinction does
not exist, these operations are identity functions. For example:
uc(’a’) == ’A’
dc(’A’) == ’a’
uc(’1’) == ’1’
dc(’1’) == ’1’
Ordering functions defined over character are defined by mapping to their Uni-
code values and using ordering operators defined in natural. A character is less than
another if its associated Unicode value is less than the other’s Unicode value. For
example, assuming that x and y are characters, x<y and x=<y are defined:
x<y==ord(x) < ord(y)
x =< y == ord(x) =< ord(y)
Table 4.8 Operators defined over the character type
Operator Syntax Return Type
Ordinal ord(a) natural
Character char(n) character
Relational Operations a<b, a=<b, boolean
a>b, a>=b
Capitalization uc(a), dc(a) character
Unicode constant former ’U+XXXX’ character
Character constant former ’x’ character

Get System Level Design with Rosetta now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.