# 8.3: Characters


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 backspace, cr, escape, euro, space, tab, and so on. Character space = (Character value: Character space asciiValue) → true  The 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: isAlphaNumeric, isCharacter, isDigit, isLowercase, isVowel, and so on.

To convert a Character to the string containing just that character, send asString. In this case asString and printString yield different results:

$a asString → 'a'$a                 →    $a$a printString     →    '$a'  Every ascii Character is a unique instance, stored in the class variable CharacterTable: (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


This page titled 8.3: Characters is shared under a CC BY-SA 3.0 license and was authored, remixed, and/or curated by Andrew P. Black, Stéphane Ducasse, Oscar Nierstrasz, Damien Pollet via source content that was edited to the style and standards of the LibreTexts platform; a detailed edit history is available upon request.