Character
ClassThe value of Character
class objects is (on most hardware
platforms) an 8-bit integer corresponding to the ISO-8859-1 character
set.
Ctalk recognizes the following escape sequences as character constants.
\a Alert \b Bell \e Escape \f Form Feed \n New line \r Carraige return \t Horizontal tab \v Vertical tab \0 NUL \" Literal double quote. \' Literal single quote.
The ‘\e’ escape sequence is an extension to the C language standard.
Ctalk itself doesn’t interpret the character constants, though - it simply recognizes that the character or escaped character can be part of a literal string or character. However, if a method encounters a constant, it should interpret the character constant based on the method’s function.
Very often a character constant’s value is enclosed in single quotes
if they are part of the token’s name. Again it’s up to the method to
interpret the character’s value. The Ctalk library includes the
macros TRIM_CHAR()
and TRIM_CHAR_BUF()
that can remove
the quotes from the character sequences if necessary.
Note: Ctalk does not support negative Characters
(i.e.,
ch
< 0) universally, even though C char
types are
“signed” by default. This is due to the uneven support in the Ctalk
and C libraries for negative characters. So if you need negative values,
it’s generally safer to use Integers
.
Additionally, if an expression doesn’t need a separate buffer for
function arguments, it can also use the CHAR_CONSTANT_VALUE
macro, which returns a string with the first character pointing to the
Character constant’s actual value. The argument to the macro is a C
char *
. Here is an example of how to store the value of a
Character object in a C char
.
char c; OBJECT *self_value; self_value = self value; sscanf (CHAR_CONSTANT_VALUE(self_value -> __o_value), "%c", &c);
value
The value of an 8-bit character in the ISO-8859-1 character set.
!
(void
)
Return a character value of true if the receiver evaluates to zero, false otherwise.
!=
(char
character)
Returns true if the receiver is not equal to character.
&
(char
character)
Returns a bitwise AND of the receiver and the argument.
&&
(char
character)
Returns TRUE
if both operands are TRUE,
FALSE
otherwise.
*
(char
c)
Multiply the receiver and the operand. The result is a Character
object.
*=
(char
c)
Multiply the receiver by the operand, and return the receiver.
+
(char
c)
Add the receiver and the operand. The result is a Character
object.
++
(void
)
The prefix and postfix increment operators for Character
objects.
+=
(char
c)
Add the operand to the receiver and the operand and return the receiver.
-
(char
c)
Subtract the receiver and the operand. The result is a Character
object.
--
(void
)
The prefix and postfix decrement operators for Character
objects.
-=
(char
c)
Subtract the operand from the receiver and return the receiver.
/
(char
c)
Divide the receiver and the operand. The result is a Character
object.
/=
(char
c)
Divide the receiver by the operand and return the receiver.
<
(char
character)
Returns TRUE
if the receiver is less than the operand, FALSE
otherwise.
<<
(int
i)
Shift the receiver left by the number of bits in the operand, which
must be an Integer
.
<=
(char
character)
Returns TRUE
if the receiver is less than or equal to the operand,
FALSE otherwise.
=
(char
character)
Set the value of the receiver object to character.
>
(char
character)
Returns TRUE
if the receiver is greater than the operand, FALSE
otherwise.
>>
(int
i)
Shift the receiver right by the number of bits in the operand, which
must be an Integer
.
>=
(char
character)
Returns TRUE
if the receiver is greater than or equal to the operand,
FALSE otherwise.
==
(char
character)
Returns true if the receiver is equal to character.
^
(char
character)
Returns a bitwise XOR of the receiver and the argument.
Returns a Character
object that is the bitwise
complement of the receiver. This method simply
calls bitComp
, below.
bitComp
(void
)
Perform a bitwise complement of the receiver.
invert
(void
)
Returns TRUE
if the receiver evaluates to FALSE,
FALSE
if the receiver evaluates to TRUE.
isASCII
(void
)
Returns TRUE
if the receiver is a 7-bit ASCII character ‘0-127’,
FALSE otherwise.
isAlNum
(void
)
Returns TRUE
if the receiver is an alphanumeric character ‘0-9’,
‘A-Z’, ‘a-z’, FALSE
otherwise.
isAlpha
(void
)
Returns TRUE
if the receiver is an alphabetic character
‘A-Z’, ‘a-z’, FALSE
otherwise.
isBlank
(void
)
Returns TRUE
if the receiver is a space ‘ ’ or horizontal
tab ‘\t’ character, FALSE
otherwise.
isCntrl
(void
)
Returns TRUE
if the receiver is a control character, FALSE
otherwise.
isDigit
(void
)
Returns TRUE
if the receiver is a character ‘0-9’, FALSE
otherwise.
isGraph
(void
)
Returns TRUE
if the receiver is any character except a space, FALSE
otherwise.
isLower
(void
)
Returns TRUE
if the receiver is a lower case character, FALSE
otherwise.
isPrint
(void
)
Returns TRUE
if the receiver is a printable character, FALSE
otherwise.
isPunct
(void
)
Returns TRUE
if the receiver is a printable non-alphanumeric
character, FALSE
otherwise.
isSpace
(void
)
Returns TRUE
if the receiver is a space, horizontal tab (\t
),
newline (\n
), vertical tab (\v
), form feed (\f
),
or carriage return (\r
) character, FALSE
otherwise.
isUpper
(void
)
Returns TRUE
if the receiver is an upper case letter, FALSE
otherwise.
isXDigit
(void
)
Returns TRUE
if the receiver is a character ‘0-9’,
‘a-f’, or ‘A-F’, FALSE
otherwise.
toLower
(void
)
If the receiver is an upper case letter, returns the lower case version.
toUpper
(void
)
If the receiver is a lower case letter, returns the upper case version.
|
(char
character)
Returns a bitwise OR of the receiver and the argument.
||
(char
character)
Returns TRUE
if either operand is TRUE,
FALSE
otherwise.