Chapter 13
Characters

 13.1 Character Attributes
 13.2 Predicates on Characters
 13.3 Character Construction and Selection
 13.4 Character Conversions

Common Lisp provides a character data type; objects of this type represent printed symbols such as letters.

In general, characters in Common Lisp are not true objects; eq cannot be counted upon to operate on them reliably. In particular, it is possible that the expression

(let ((x z) (y z)) (eq x y))

may be false rather than true, if the value of z is a character. ___________

Rationale: This odd breakdown of eq in the case of characters allows the implementor enough design freedom to produce exceptionally efficient code on conventional architectures. In this respect the treatment of characters exactly parallels that of numbers, as described in chapter 12.

___________________________________________________________________________________________________________


Table 13.1: Standard Character Labels, Glyphs, and Descriptions
  SM05@ commercial at SD13 grave accent
SP02  ! exclamation mark LA02 A capital A LA01 a small a
SP04  " quotation mark LB02 B capital B LB01 b small b
SM01 #number sign LC02 C capital C LC01 c small c
SC03  $ dollar sign LD02 D capital D LD01 d small d
SM02 %percent sign LE02 E capital E LE01 e small e
SM03 &ampersand LF02 F capital F LF01 f small f
SP05   apostrophe LG02G capital G LG01g small g
SP06  ( left parenthesis LH02 H capital H LH01 h small h
SP07  ) right parenthesis LI02 I capital I LI01 i small i
SM04 * asterisk LJ02 J capital J LJ01 j small j
SA01  +plus sign LK02K capital K LK01k small k
SP08  , comma LL02 L capital L LL01 l small l
SP10  - hyphen or minus signLM02Mcapital M LM01msmall m
SP11  . period or full stop LN02 N capital N LN01 n small n
SP12  / solidus LO02 O capital O LO01 o small o
ND10 0 digit 0 LP02 P capital P LP01 p small p
ND01 1 digit 1 LQ02 Q capital Q LQ01 q small q
ND02 2 digit 2 LR02 R capital R LR01 r small r
ND03 3 digit 3 LS02 S capital S LS01 s small s
ND04 4 digit 4 LT02 T capital T LT01 t small t
ND05 5 digit 5 LU02 U capital U LU01 u small u
ND06 6 digit 6 LV02 V capital V LV01 v small v
ND07 7 digit 7 LW02Wcapital W LW01wsmall w
ND08 8 digit 8 LX02 X capital X LX01 x small x
ND09 9 digit 9 LY02 Y capital Y LY01 y small y
SP13  : colon LZ02 Z capital Z LZ01 z small z
SP14  ; semicolon SM06[ left square bracket SM11{ left curly bracket
SA03  <less-than sign SM07\ reverse solidus SM13| vertical bar
SA04  =equals sign SM08] right square bracketSM14} right curly bracket
SA05  >greater-than sign SD15 ̂ circumflex accent SD19 ~ tilde
SP15  ? question mark SP09 _ low line

The characters in this table plus the space and newline characters make up the standard Common Lisp character repertoire (type standard-char). The character labels and character descriptions shown here are taken from ISO standard 6937/2 . The first character of the label categorizes the character as Latin, Numeric, or Special.


If two objects are to be compared for “identity,” but either might be a character, then the predicate eql is probably appropriate.