![]() |
Section 8.3.2.9:
|
![]() |
types SAME = UTF7 ; UTF7 = token ;
This class provides for conversion of encoding sequences (ie text strings in some encoding) to a sequence of one or more octets in which a clear octet is only found when the original encoding was void.
The algorithm provided is designed to achieve the translation given in the following table in which v signifies a value bit of the original code.
Bits | Hex Min | Hex Max | Octet Sequence in Binary |
7 | 00000000 | 0000007F | 0vvvvvvv |
11 | 00000080 | 000007FF | 110vvvvv 10vvvvvv |
16 | 00000800 | 0000FFFF | 1110vvvv 10vvvvvv 10vvvvvv |
21 | 00010000 | 001FFFFF | 11110vvv 10vvvvvv 10vvvvvv 10vvvvvv |
26 | 00200000 | 03FFFFFF | 111110vv 10vvvvvv 10vvvvvv 10vvvvvv 10vvvvvv |
31 | 04000000 | 7FFFFFFF | 1111110v 10vvvvvv 10vvvvvv 10vvvvvv 10vvvvvv 10vvvvvv |
Note that two octets are required to transform eight-bit encodings. When there are multiple ways to transform a single encoding, for example UCS 0, only the shortest transformation is legal.
The original character encoding may be obtained by concatenating the v bits into a (possibly multiple) octet encoding.
The following feature is required to be implemented for this class in accordance with the specification given in $IS_EQ :-
The following features are required to be implemented for this class in accordance with the specifications given by inheritance in $STR of which $IMMUTABLE 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 $IMMUTABLE is a sub-type:-
This feature creates a UTF7 encoding of the bit-pattern contained in the argument value.
create2(val : CARD) res : SAME
Since the argument is not optional this pre-condition is vacuously true.
post card(res) = self
This feature creates and returns a UTF7 encoding corresponding to the given numeric value (treated as a bit-pattern).
This feature creates a UTF7 encoding from the given rune argument - which may consist of one or more individual encodings. The rune code kind is discarded in this transformation.
create3(rn : RUNE) res : SAME
Since the argument is not optional this pre-condition is vacuously true.
post runes(res)(1) = self
This feature creates and returns a UTF7 encoding corresponding to the given rune encoding.
This feature creates a UTF7 encoding from the given rune string argument. The rune code kind is discarded in this transformation.
Note that the result of this operation is of the same form as when converting a single (multiple encoding) rune.
create3(rn : RUNES) res : SAME
Since the argument is not optional this pre-condition is vacuously true.
post runes(res) = self
This feature converts the given rune string which is a sequence of runes for conversion into a valid UTF7 code.
This feature builds a UTF7 encoding from the indicated binary string buffer - using all of the buffer contents from the current cursor position. The rune code kind is discarded in this transformation.
Note that the result of this operation is of the same form as when converting a single (multiple encoding) rune.
build | ( |
octets : BIN_CURSOR, | |
lib : LIBCHARS | |
) : SAME |
build2(octets : BIN_CURSOR, lib : LIBCHARS) res : SAME
pre BIN_CURSOR.remaining(octets) mod LIBCHARS.my_size(lib) = 0
post let loc_runes = RUNES.build(octets,lib) in runes(res) = loc_runes
This feature converts the indicated binary string into a valid UTF7 code using the given repertoire and encoding.
This predicate returns true if and only if self is the transformation of a single character encoding.
is_singleton(self : SAME) res : BOOL
Since this routine is a predicate the pre-condition is vacuously true.
post res = (RUNE.size(runes(self)(1)) = 1)
This feature returns true if and only if self is the transformation of a single character encoding.
This feature transforms self into a numeric value provided that self only contains a single character coding.
card(self : SAME) res : CARD
pre is_singleton(self)
post create(res) = self
This feature returns the encoded bits of self as a numeric value providing that self is merely a single transformed encoding.
This feature transforms self into a rune string in the indicated repertoire and encoding.
runes(self : SAME, lib : LIBCHARS) res : RUNES
Since neither argument is optional this pre-condition is vacuously true.
post create(res) = self
This feature returns a string consisting of the individual codes of self treated as a rune string in the given repertoire and encoding.
This feature transforms self into a rune string in the indicated repertoire and encoding.
runes2(self : SAME) res : RUNES
Since the argument is not optional this pre-condition is vacuously true.
post create(res) = self
This feature returns a string consisting of the individual codes of self treated as a rune string in the default repertoire and encoding.
This feature transforms self into a local environment character string using the default repertoire and encoding. If self is a transformation of a character code within table 0 of the Unicode standard then the result will be identical in bit-pattern to self. This is the reason for the existence of UTF7 as a coding which can be used to name files across computer systems in different cultures - see the POSIX standard.
tgt_str(self : SAME) res : STR
Since the argument is not optional, this pre-condition is vacuously true.
post res = RUNES.str(runes(self))
This feature transforms self into the locally defined default character string using eight, sixteen or thirty-two bit code spaces as defined in the environment.
This iter yields in sequence the individual transformations of single encodings contained in self - in the given cultural context.
Note that the formal name of the iter has been changed to replace the exclamation mark iter symbol to a name acceptable to vdm tools.
rune_iter(self : SAME, lib : LIBCHARS) yld : SAME
Since the argument is not optional then this pre-condition is vacuously true.
This post-condition makes use of the history concept from vdm++ (see the vdm dialect notes).
post let rns : seq of RUNE be st create(rns) = self in RUNE.lib(yld) = lib and yld = rns(card history~ + 1) and history = history~ ^ yld
For quit actions see the specification of the quit statement.
errs QUIT : let rns : seq of RUNE be st rns = self in card history = card rns -> quit
This iter yields in sequence individual runes of which self is a sequence of transformations in the given encoding and repertoire.
This iter yields in sequence the individual transformations of single encodings contained in self.
Note that the formal name of the iter has been changed to replace the exclamation mark iter symbol to a name acceptable to vdm tools.
rune_iter2(self : SAME) yld : SAME
Since the argument is not optional then this pre-condition is vacuously true.
This post-condition makes use of the history concept from vdm++ (see the vdm dialect notes).
post let rns : seq of RUNE be st create(rns) = self in RUNE.lib(yld) = LIBCHARS.default and yld = rns(card history~ + 1) and history = history~ ^ yld
For quit actions see the specification of the quit statement.
errs QUIT : let rns : seq of RUNE be st rns = self in card history = card rns -> quit
This iter yields in sequence individual runes of which self is a sequence of transformations in the default encoding and repertoire.
This iter yields in sequence the individual transformations of single encodings contained in self.
Note that the formal name of the iter has been changed to replace the exclamation mark iter symbol to a name acceptable to vdm tools.
code_iter(self : SAME) yld : SAME
Since the argument is not optional then this pre-condition is vacuously true.
This post-condition makes use of the history concept from vdm++ (see the vdm dialect notes).
post let codes : seq of SAME be st codes = self in yld = codes(card history~ + 1) and history = history~ ^ yld
For quit actions see the specification of the quit statement.
errs QUIT : let codes : seq of SAME be st codes = self in card history = card codes -> quit
This iter yields in sequence individual character coding transformations.
![]() |
Language Index | ![]() |
Library Index | ![]() |
Codes Index |
Comments
or enquiries should be made toKeith Hopper. Page last modified: Friday, 27 April 2001. |
![]() |