Back: CFunctionDescriptor-restoring Up: Base classes Forward: Character class-built ins   Top: GNU Smalltalk Library Reference Contents: Table of Contents Index: Class index About: About this document

1.27 Character

Defined in namespace Smalltalk
Superclass: Magnitude
Category: Language-Data types
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.

1.27.1 Character class: built ins  (class)
1.27.2 Character class: constants  (class)
1.27.3 Character class: initializing lookup tables  (class)
1.27.4 Character class: instance creation  (class)
1.27.5 Character class: testing  (class)
1.27.6 Character: built ins  (instance)
1.27.7 Character: coercion methods  (instance)
1.27.8 Character: comparing  (instance)
1.27.9 Character: converting  (instance)
1.27.10 Character: printing  (instance)
1.27.11 Character: storing  (instance)
1.27.12 Character: testing  (instance)
1.27.13 Character: testing functionality  (instance)


1.27.1 Character class: built ins

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.


1.27.2 Character class: constants

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'


1.27.3 Character class: initializing lookup tables

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.


1.27.4 Character class: instance creation

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


1.27.5 Character class: testing

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


1.27.6 Character: built ins

= 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.


1.27.7 Character: coercion methods

* 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.


1.27.8 Character: comparing

< 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.


1.27.9 Character: converting

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.


1.27.10 Character: printing

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


1.27.11 Character: storing

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

storeOn: aStream
Store Smalltalk code compiling to the receiver on aStream


1.27.12 Character: testing

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


1.27.13 Character: testing functionality

isCharacter
Answer True. We're definitely characters



Back: Character-testing Up: Character Forward: CharacterArray   Top: GNU Smalltalk Library Reference Contents: Table of Contents Index: Class index About: About this document


This document was generated on February, 22 2012 using texi2html