Character and String Types
**************************

The :SB-UNICODE feature implies support for all 1114112 potential characters in the character space defined by the Unicode consortium, with the identity mapping between lisp char-code and Unicode code point.  SBCL releases before version 0.8.17, and those without the :SB-UNICODE feature, support only 256 characters, with the identity mapping between char-code and Latin1 (or, equivalently, the first 256 Unicode) code point.

In the absence of the :SB-UNICODE feature, the types base-char and character are identical, and encompass the set of all 256 characters supported by the implementation.  With the :SB-UNICODE on *features* (the default), however, base-char and character are distinct: character encompasses the set of all 1114112 characters, while base-char represents the set of the first 128 characters.

The effect of this on string types is that an SBCL configured with :SB-UNICODE has three disjoint string types: (vector nil), base-string and (vector character).  In a build without :SB-UNICODE, there are two such disjoint types: (vector nil) and (vector character); base-string is identically equal to (vector character).

The SB-KERNEL:CHARACTER-SET-TYPE represents possibly noncontiguous sets of characters as lists of range pairs: for example, the type standard-char is represented as the type (sb-kernel:character-set '((10 . 10) (32 . 126)))

Memory Layout
=============

Characters are immediate objects (that is, they require no heap allocation) in all permutations of build-time options.  Even on a 32-bit platform with :SB-UNICODE, there are three bits to spare after allocating 8 bits for the character widetag and 21 for the character code.  There is only one such layout, and consequently only one widetag is needed: the difference between base-char and character is purely on the magnitude of the char-code.

Objects of type (simple-array nil (*)) are represented in memory as two words: the first is the object header, with the appropriate widetag, and the second is the length field.  No memory is needed for elements of these objects, as they can have none.

Objects of type simple-base-string have the header word with widetag, then a word for the length, and after that a sequence of 8-bit char-code bytes.  The system arranges for there to be a null byte after the sequence of lisp character codes.

Objects of type (simple-array character (*)), where this is a distinct type from simple-base-string, have the header word with widetag, length, and then a sequence of 32-bit char-code bytes. Again, the system arranges for there to be a null word after the sequence of character codes.

Non-simple character arrays, and simple character arrays of non-unit dimensionality, have an array header with a reference to an underlying data array of the appropriate form from the above representations.

Reader and Printer
==================

The " reader macro always constructs an object of type (simple-array character), even if all of the characters within the quotation marks are of type base-char.  This implies that only strings of type (vector character) will be able to be printed when *print-readably* is true: attempting to print strings of other types will cause an error of type print-not-readable.