Category: Language-Data types
Superclass: Magnitude
My instances represent the 256 characters of the character set. I provide messages to translate between integers and character objects, and provide names for some of the common unprintable characters. Character is always used (mostly for performance reasons) when referring to characters whose code point is between 0 and 127. Above 127, instead, more care is needed: Character refers to bytes that are used as part of encoding of a character, while UnicodeCharacter refers to the character itself.

Method category index

built ins (class)
constants (class)
initializing lookup tables (class)
instance creation (class)
testing (class)
built ins (instance)
coercion methods (instance)
comparing (instance)
converting (instance)
printing (instance)
storing (instance)
testing (instance)
testing functionality (instance)

built ins (class)

asciiValue: anInteger
Returns the character object corresponding to anInteger. Error if anInteger is not an integer, or not in 0..127.

codePoint: anInteger

Returns the character object, possibly an UnicodeCharacter, corresponding to anInteger. Error if anInteger is not an integer, or not in 0..16r10FFFF.

value: anInteger

Returns the character object corresponding to anInteger. Error if anInteger is not an integer, or not in 0..255.

top


constants (class)

backspace
Returns the character 'backspace'

bell

Returns the character 'bel'

cr

Returns the character 'cr'

eof

Returns the character 'eof', also known as 'sub'

eot

Returns the character 'eot', also known as 'Ctrl-D'

esc

Returns the character 'esc'

ff

Returns the character 'ff', also known as 'newPage'

lf

Returns the character 'lf', also known as 'nl'

newPage

Returns the character 'newPage', also known as 'ff'

nl

Returns the character 'nl', also known as 'lf'

nul

Returns the character 'nul'

space

Returns the character 'space'

tab

Returns the character 'tab'

top


initializing lookup tables (class)

initialize
Initialize the lookup table which is used to make case and digit-to-char conversions faster. Indices in Table are ASCII values incremented by one. Indices 1-256 classify chars (0 = nothing special, 2 = separator, 48 = digit, 55 = uppercase, 3 = lowercase), indices 257-512 map to lowercase chars, indices 513-768 map to uppercase chars.

top


instance creation (class)

digitValue: anInteger
Returns a character that corresponds to anInteger. 0-9 map to $0-$9, 10-35 map to $A-$Z

top


testing (class)

isImmediate
Answer whether, if x is an instance of the receiver, x copy == x

top


built ins (instance)

= char
Boolean return value; true if the characters are equal

asInteger

Returns the integer value corresponding to self. #codePoint, #asciiValue, #value, and #asInteger are synonyms.

asciiValue

Returns the integer value corresponding to self. #codePoint, #asciiValue, #value, and #asInteger are synonyms.

codePoint

Returns the integer value corresponding to self. #codePoint, #asciiValue, #value, and #asInteger are synonyms.

value

Returns the integer value corresponding to self. #codePoint, #asciiValue, #value, and #asInteger are synonyms.

top


coercion methods (instance)

* aNumber
Returns a String with aNumber occurrences of the receiver.

asLowercase

Returns self as a lowercase character if it's an uppercase letter, otherwise returns the character unchanged.

asString

Returns the character self as a string. Only valid if the character is between 0 and 255.

asSymbol

Returns the character self as a symbol.

asUnicodeString

Returns the character self as a Unicode string.

asUppercase

Returns self as a uppercase character if it's an lowercase letter, otherwise returns the character unchanged.

top


comparing (instance)

< aCharacter
Compare the character's ASCII value. Answer whether the receiver's is the least.

<= aCharacter

Compare the character's ASCII value. Answer whether the receiver's is the least or their equal.

> aCharacter

Compare the character's ASCII value. Answer whether the receiver's is the greatest.

>= aCharacter

Compare the character's ASCII value. Answer whether the receiver's is the greatest or their equal.

top


converting (instance)

asCharacter
Return the receiver, since it is already a character.

digitValue

Returns the value of self interpreted as a digit. Here, 'digit' means either 0-9, or A-Z, which maps to 10-35.

top


printing (instance)

displayOn: aStream
Print a representation of the receiver on aStream. Unlike #printOn:, this method strips the leading dollar.

printOn: aStream

Print a representation of the receiver on aStream

storeLiteralOn: aStream

Store on aStream some Smalltalk code which compiles to the receiver

top


storing (instance)

isLiteralObject
Answer whether the receiver is expressible as a Smalltalk literal.

storeOn: aStream

Store Smalltalk code compiling to the receiver on aStream

top


testing (instance)

isAlphaNumeric
True if self is a letter or a digit

isDigit

True if self is a 0-9 digit

isDigit: radix

Answer whether the receiver is a valid character in the given radix.

isLetter

True if self is an upper- or lowercase letter

isLowercase

True if self is a lowercase letter

isPathSeparator

Returns true if self is a path separator ($/ or $\ under Windows, $/ only under Unix systems including Mac OS X).

isPunctuation

Returns true if self is one of '.,:;!?'

isSeparator

Returns true if self is a space, cr, tab, nl, or newPage

isUppercase

True if self is uppercase

isVowel

Returns true if self is a, e, i, o, or u; case insensitive

top


testing functionality (instance)

isCharacter
Answer True. We're definitely characters

top