Character
The class Character is an abstraction for character data. Characters have values between 0 and 65535, and are unique objects that represent code points. A code point is simply a numeric value--the format and graphical appearance of a character are defined by the currently selected character set. All vendors agree that the characters with values from 0-127 correspond to the ASCII standard character set. However, there is no agreement on the interpretation of other characters. Groups of characters can be composed into either a String or a DBString depending upon the values of the characters being composed.
Note:
Many of the original Smalltalk implementations supported only characters that could be represented by a single byte (characters in the range 0 to 255). Currently, implementations of Objectworks\Smalltalk and Smalltalk/V provide for characters whose value exceeds 255. Characters whose values exceed 255 require two bytes of storage, and are often referred to as double-byte characters. Double-byte character support is critical for the development of applications for the international market place because many languages use more than 256 characters.
Accessing
value, digitValue
Porting tip:
CLDT does not support the Blue Book method asciiValue because it is not appropriate for characters whose value exceeds 127, the range of values converted by the ASCII standard. Rather, the asciiValue message is replaced by the more general message value. Objectworks\Smalltalk does not support the message value, but uses asInteger as the equivalent message. Smalltalk/V does not support the message value, but uses asciiValue as the equivalent message.
Converting
asLowercase, asSymbol, asUppercase, asString
Porting tip:
Smalltalk/V uses the spelling asLowerCase and asUpperCase, and does not support asSymbol. Character conversions outside the ASCII range of values (0 to 127) vary from platform to platform and from language to language. Character conversion results might differ between platforms. Objectworks\Smalltalk does not support asString.
Creating instances (Character class)
digitValue:, value:, codePoint: (ANSI)
Note:
The Blue Book specifies that class
Character should support messages that provide access to several of the standard ASCII nonprinting characters used for text formatting:
backspace,
cr,
esc,
newPage,
space, and
tab.
Objectworks\Smalltalk adopts this approach, and extends it to support several additional characters. The approach taken by VA Smalltalk is to supply all of the nonprinting ASCII characters in a pool dictionary called
CldtConstants as shown in
Table 2. In addition, to support the ANSI Smalltalk specification,
cr,
if,
space, and
tab are provided.
Porting tip:
Smalltalk/V does not support the message value:.
Table 2. The CldtConstants pool dictionary
| | | |
Ack | 6 | Ff | 12 |
Bell | 7 | Fs | 28 |
Bs | 8 | Gs | 29 |
Can | 24 | Lf | 10 |
Cr | 13 | Nak | 21 |
Dc1 | 17 | Nul | 0 |
Dc2 | 18 | Rs | 30 |
Dc3 | 19 | Si | 15 |
Dc4 | 20 | So | 14 |
Del | 127 | Soh | 1 |
Dle | 16 | Space | 32 |
Em | 25 | Stx | 2 |
Enq | 5 | Sub | 26 |
Eot | 4 | Syn | 22 |
Esc | 27 | Tab | 9 |
Etb | 23 | Us | 31 |
Etx | 3 | Vt | 11 |
Table 3. The CldtConstants pool dictionary
(LineDelimiter values)
| |
LineDelimiter | The platform-specific line delimiter string |
PMLineDelimiter | The string consisting of Cr followed by Lf |
UNIXLineDelimeter | The string consisting of Lf |
WINLineDelimiter | The string consisting of Cr followed by Lf |
Testing
isAlphaNumeric, isDigit, isLetter, isLowercase, supplantation, isSeparator, isUppercase, isVowel
Porting tip:
Smalltalk/V uses the spelling isLowerCase and isUpperCase. Character classifications outside the ASCII range of values (0 to 127) vary from platform to platform and from language to language. Character conversion results might differ between platforms. Neither Objectworks\Smalltalk nor Smalltalk/V support isPunctuation for Characters.
Last modified date: 04/20/2020