base-char
base-char Type
Supertypes:
base-char, character, t
Description:
The type base-char is defined as the upgraded array element type of standard-char. An implementation can support additional subtypes of type character (besides the ones listed in this standard) that might or might not be supertypes of type base-char. In addition, an implementation can define base-char to be the same type as character.
Base characters are distinguished in the following respects:
1. The type standard-char is a subrepertoire of the type base-char.
2. The selection of base characters that are not standard characters is implementation defined.
3. Only objects of the type base-char can be elements of a base string.
4. No upper bound is specified for the number of characters in the base-char repertoire; the size of that repertoire is implementation-defined. The lower bound is 96, the number of standard characters.
Whether a character is a base character depends on the way that an implementation represents strings, and not any other properties of the implementation or the host operating system. For example, one implementation might encode all strings as characters having 16-bit encodings, and another might have two kinds of strings: those with characters having 8-bit encodings and those with characters having 16-bit encodings. In the first implementation, the type base-char is
equivalent to the type character: there is only one kind of string. In the second implementation, the base characters might be those characters that could be stored in a string of characters having 8-bit encodings. In such an implementation, the type base-char is a proper subtype of the type character.
The type standard-char is a subtype of type base-char.
Expanded Reference: base-char
Type checking with base-char
base-char is the type of characters that can be elements of a base string. All standard characters are base characters.
(typep #\a 'base-char)
=> T
(typep #\Z 'base-char)
=> T
(typep #\5 'base-char)
=> T
(typep #\Space 'base-char)
=> T
Relationship to character and standard-char
standard-char is a subtype of base-char, which is a subtype of character. In many implementations, base-char is the same type as character.
(subtypep 'standard-char 'base-char)
=> T
=> T
(subtypep 'base-char 'character)
=> T
=> T
Base strings use base-char elements
The element type of a base string is base-char. This is the connection between the character type and string storage.
(typep "hello" 'base-string)
;; => T or NIL (implementation-dependent)
(array-element-type (make-string 5))
;; => CHARACTER or BASE-CHAR (implementation-dependent)
(upgraded-array-element-type 'standard-char)
=> BASE-CHAR
Using base-char as a type specifier
You can use base-char in type declarations and coerce operations.
(let ((chars (make-array 3 :element-type 'base-char
:initial-contents '(#\a #\b #\c))))
(values (aref chars 0)
(array-element-type chars)))
=> #\a
=> BASE-CHAR