2.1 New data types
character. Character objects were encoded as single-byte characters that could have bits and font attributes.
In this release, Liquid Common Lisp adds new character types and subtypes to the Common Lisp type hierarchy to support both single-byte and double-byte characters.
The following new character type specifiers have been added to the Common Lisp type hierarchy:
), a subtype of
base-character, a subtype of
standard-character, a subtype of
extended-character, a subtype of
)specifies a character in a particular character repertoire.
A character repertoire is an unordered set of abstract characters; it does not specify the encoding of the characters. Liquid Common Lisp supports the following character repertoires:
Type specifiers denoting the base character repertoire.
For the HP and RS6000 platforms, the base character repertoire contains the standard ASCII characters.
For the SunOS and Solaris platforms, the base character repertoire contains those ASCII characters that are in Extended UNIX Code (EUC) codeset 0.
Base characters are represented as single-byte characters. The base character repertoire can overlap with characters from other repertoires, such as
base-character is synonymous with
Type specifier denoting the repertoire of characters that consists of the 96 standard characters as defined by CLtL2. This type is a subtype of
standard-char is synonymous with
(character :standard) and is a subtype of
Type specifier denoting the English alphabet.
Type specifier denoting Japanese Kanji characters.
Type specifier denoting Japanese Katakana characters.
Type specifier denoting Japanese Hiragana characters.
Type specifier denoting any single-byte character.
Type specifier denoting any double-byte character.
extended-characterdenotes all characters that are not base characters. Extended characters are full-fledged Common Lisp characters; that is, you can use extended characters wherever you would use any Common Lisp character. In particular, you can construct symbol names and package names with extended characters, base characters, or a combination of extended and base characters.
For example, if you could type Greek characters as well as ASCII characters from your keyboard, you could have the following interaction with Lisp:
> (setq f '(1 2 3)) (1 2 3)Extended characters are represented as double-byte characters.
> (car f) 1
> (defun g (c) (car c)) g
> (g f) 1
> (defvar *c* '(9 8 7)) *c*
> (g *c*) 9
> (setq mixed-string "c-987") "c-987"
> mixed-string "c-987"
Table 2.1 shows which coded character set represents the extended characters for each supported platform.
|Platform||Coded Character Set|
|RS6000||PC932 (Shift JIS)|
|SunOS/Solaris||EUC codeset 1|
In Common Lisp, you can represent character objects by writing
#\ followed by the character. For example,
#\a represents a lowercase
a. In Liquid Common Lisp, you can also represent characters as a hexadecimal character code; for example, the letter
a can be represented as
#\c61, which is the same as
Extended characters can be represented using the same hex notation; for example, you can enter a character of the Kanji character set by using any of the following notations:
(int-char #xc7ad) #\cc7ad #\Kanji ideogramOn streams of type
character, strings of extended characters and character objects are printed out directly. On streams of type
base-character, extended characters are printed in the hex notation. For example, if you write the extended character
#\cc7ad, it is printed as
#\cC7AD. Extended characters in strings and symbol names are printed in a similar syntax. For example, the string
"abc#\cc7ad"is printed as
#<"abc[C7AD]">, and the symbol name
abc#\cc7adis printed as
The type specifier
augmented-character is equivalent to
character except when used for character I/O operations. Specifically, when
augmented-character is specified as the value of the
:element-type keyword argument to
make-lisp-stream, bits and font attributes are preserved; for all other element types, bits and font attributes are ignored. See Chapter 3, "Using Characters and Strings" for a complete description of the
:element-type keyword option.
Figure 2.1 shows the additions to the character type hierarchy and their relationship to the type
character, which is the union of the types
Figure 2.1 Character type hierarchy
Generated with Harlequin WebMaker