Common Lisp the Language, 2nd Edition

Next: Line Divisions Up: Characters Previous: Characters

## 2.2.1. Standard Characters

Common Lisp defines a standard character set (subtype `standard-char`) for two purposes. Common Lisp programs that are written in the standard character set can be read by any Common Lisp implementation; and Common Lisp programs that use only standard characters as data objects are most likely to be portable. The Common Lisp character set consists of a space character `#\Space`, a newline character `#\Newline`, and the following ninety-four non-blank printing characters or their equivalents:

    ! " # $ % & ' ( ) * + , - . / 0 1 2 3 4 5 6 7 8 9 : ; < = > ?
    @ A B C D E F G H I J K L M N O P Q R S T U V W X Y Z [ \ ] ^ _
    ` a b c d e f g h i j k l m n o p q r s t u v w x y z { | } ~

The Common Lisp standard character set is apparently equivalent to the ninety-five standard ASCII printing characters plus a newline character. Nevertheless, Common Lisp is designed to be relatively independent of the ASCII character encoding. For example, the collating sequence is not specified except to say that digits must be properly ordered, the uppercase letters must be properly ordered, and the lowercase letters must be properly ordered (see `char<` for a precise specification). Other character encodings, particularly EBCDIC, should be easily accommodated (with a suitable mapping of printing characters).

Of the ninety-four non-blank printing characters, the following are used in only limited ways in the syntax of Common Lisp programs:

    [  ]  {  }  ?  !  ^  _  ~  $  %

All of these characters except `!` and `_` are used within `format` strings as formatting directives. Except for this, `[`, `]`, `{`, `}`, `?`, and `!` are not used in Common Lisp and are reserved to the user for syntactic extensions; `^` and `_` are not yet used in Common Lisp but are part of the syntax of reserved tokens and are reserved to implementors; `~` is not yet used in Common Lisp and is reserved to implementors; and `$` and `%` are normally regarded as alphabetic characters but are not used in the names of any standard Common Lisp functions, variables, or other entities.

X3J13 voted in June 1989 (PRETTY-PRINT-INTERFACE) to add a `format` directive `~_` (see chapter 27).

The following characters are called semi-standard:

    #\Backspace  #\Tab  #\Linefeed  #\Page  #\Return  #\Rubout

Not all implementations of Common Lisp need to support them; but those implementations that use the standard ASCII character set should support them, treating them as corresponding respectively to the ASCII characters BS (octal code 010), HT (011), LF (012), FF (014), CR (015), and DEL (177). These characters are not members of the subtype `standard-char` unless synonymous with one of the standard characters specified above. For example, in a given implementation it might be sensible for the implementor to define `#\Linefeed` or `#\Return` to be synonymous with `#\Newline`, or `#\Tab` to be synonymous with `#\Space`.

Next: Line Divisions Up: Characters Previous: Characters