Sather Home Page

Section 8.17.2.1:
CHAR

immutable class CHAR < $CHAR{SAME}

Inheritance map $CHAR

Formal Types

types

SAME = CHAR ;

CHAR = char

This class implements the notion of a logical character which has the semantics associated with such a token in the cultural environment concerned and which has a single encoding!

NOTE For characters which require multiple encodings see the class RUNE in this section of the required library.

External specifications

The following feature is required to be implemented for this class in accordance with the specification given in $IS_EQ of which $CHAR{CHAR} is a sub-type :-


The following feature is required to be implemented for this class in accordance with the specification given in $IS_LT{CHAR} of which $CHAR{CHAR} is a sub-type :-


The following features are required to be implemented for this class in accordance with the specifications given by inheritance in $STR of which $CHAR{CHAR} is a sub-type :-


The following feature is required to be implemented for this class in accordance with the specification given in $HASH of which $CHAR{CHAR} is a sub-type :-


The following features are required to be implemented for this class in accordance with the specifications given in $BINARY of which $CHAR{CHAR} is a sub-type :-


The following features are required to be implemented for this class in accordance with the specifications given in $INSTR of which $CHAR{CHAR} is a sub-type :-


The following features are required to be implemented for this class in accordance with the specifications given in $ANCHORED_FMT of which $CHAR{CHAR} is a sub-type :-


The following features are required to be implemented for this class in accordance with the specifications given in $CHAR{CHAR} :-


valid

This predicate is provided in order that the validity of the 'number' as a bit-pattern for a code may be ascertained - in respect to the given encoding and repertoire.

valid (
num : CARD,
lib : LIBCHARS
) : BOOL
Formal Signature
valid(num : CARD, lib : LIBCHARS) res : BOOL
Pre-condition
pre true
Post-condition

Note that where the code is to occupy eight bits only then all values are valid, but that for sixteen bit codes all values except the one with all bits set is valid - and for thirty-two bit codes only 31 bits are used and then the value with 31 bits set is not valid.

post res =
cases LIBCHARS.my_size(lib) :
1 -> num <= OCTET.Octet_Max,
2 -> num < HEXTET.Hextet_Max,
4 -> num <= QUADBITS.Quad_Max div 2
end

This routine returns true if and only if the value of num may be interpreted as a character bit-pattern valid in the given encoding and repertoire, otherwise false.


valid

This predicate is provided in order that the validity of the 'number' as a bit-pattern for a code may be ascertained - in respect to the default encoding and repertoire.

valid (
num : CARD
) : BOOL
Formal Signature
valid(num : CARD) res : BOOL
Pre-condition
pre true
Post-condition

Note that where the code is to occupy eight bits only then all values are valid, but that for sixteen bit codes all values except the one with all bits set is valid - and for thirty-two bit codes only 31 bits are used and then the value with 31 bits set is not valid.

post res =
cases LIBCHARS.my_size(LIBCHARS.default()) :
1 -> num <= OCTET.Octet_Max,
2 -> num < HEXTET.Hextet_Max,
4 -> num <= QUADBITS.Quad_Max div 2
end

This routine returns true if and only if the value of num may be interpreted as a character bit-pattern valid in the default execution environment encoding and repertoire, otherwise false.


convert

This routine attempts to convert self - in the from_lib encoding - into the to_lib encoding if this is possible, otherwise void is returned.

convert (
from_lib : LIBCHARS,
to_lib : LIBCHARS
) : SAME
Formal Signature
convert(self : SAME, from_lib : LIBCHARS, to_lib : LIBCHARS) res : [SAME]
Pre-condition
pre true
Post-condition
post convert(res,to_lib,from_lib) = self
or res = nil

This routine converts self, which is assumed to be in the encoding and repertoire specified by the from_lib argument, into the encoding specified by to_lib - if this is possible, otherwise returning void.


convert

This routine attempts to convert self, which is presumed to be in the current default encoding into the encoding specified by the argument if this is possible, otherwise void is returned.

convert (
lib : LIBCHARS
) : SAME
Formal Signature
convert(self : SAME, lib : LIBCHARS) res : [SAME]
Pre-condition
pre true
Post-condition
post convert(res,LIBCHARS.default(),lib) = self
or res = nil

This routine converts self, which is assumed to be in the default execution environment encoding and repertoire, into the encoding specified by lib - if this is possible, otherwise returning void.


Language Index Library Index Text Index
Comments or enquiries should be made to Keith Hopper.
Page last modified: Thursday, 23 November 2000.
Produced with Amaya