Character is defined in the Collections-Strings category as a subclass of
Magnitude. Printable characters are represented in Squeak as $⟨char⟩. For example:
$a < $b → true
Non-printing characters can be generated by various class methods. Character class»value: takes the Unicode (or ASCII) integer value as argument and returns the corresponding character. The protocol accessing untypeable characters contains a number of convenience constructor methods such as
tab, and so on.
Character space = (Character value: Character space asciiValue) → true
printOn: method is clever enough to know which of the three ways to generate characters offers the most appropriate representation:
Character value: 1 → Character value: 1 Character value: 32 → Character space Character value: 97 → $a
Various convenient testing methods are built in:
isVowel, and so on.
To convert a
Character to the string containing just that character, send
asString. In this case
printString yield different results:
$a asString → 'a' $a → $a $a printString → '$a'
Character is a unique instance, stored in the class variable
(Character value: 97) == $a → true
Characters outside the range 0 to 255 are not unique, however:
Character characterTable size → 256 (Character value: 500) == (Character value: 500) → false