Eclipse Lisp: Characters


This section includes the following information:

Character Names

The following character names are defined, in addition to the ones specified as semi-standard by ANSI Common Lisp:

Character Repertoires

The following character repertoires are supported: Note that character repertoires are type specifiers usable for discrimination -- they do not necessarily have a distinct representation type. In fact, upgraded-array-element-type of any of these will always return either base-char or character.

Readtables

Any character (not just base-char) may have syntax in a readtable.

Similarity As Constants

ANSI does not permit the file-compiler to change the actual element-type of a string literal from that which was read by the reader. Thus, in general, the type of string literals produced by load and compile-file is governed by external-format and by user code that may effect how strings are read by the reader. Both load and compile-file recognize that only base-char elements can be present in the :ASCII external-format, so in this case, only base-string literals are produced by quoted strings read in the standard readtable. In other cases, string literals may be of other string types.

Note that implementations are allowed to copy and perform other optimizations at any time on the names used to intern symbols. Thus the symbol-name of a symbol which is originally created with a name that is a general string may, in fact be treated as a base-string by the system if all the characters of the name are, in fact, of type base-char.

Char-Code-Limit

Because Unicode characters are supported, char-code-limit is so large as to be meaningless as a means of iterating over characters. Eclipse defines an additional constant, base-char-code-limit, which is the upper exclusive bound on char-code for base-char.

Character Attributes

Characters in the base-char repertoire define control and meta bit attributes. These bits can be examined and set with char-bit and set-char-bit.

A control character is one which has its control bit set. ASCII control characters are non-graphic, and have char-codes below 32.

An ASCII-char does not have its meta bit set. A Latin-char which is not also an ASCII-char does have its meta bit set. Meta characters have char-codes above 127. N.B.: A meta character that is also a control character may or may not be graphic. (See Character Predicates and Case, below.)

Both the control bit and meta bit attributes are stripped off by char-code. For example,

 (char-code x) <=> (char-int (set-char-bit x :control nil :meta nil))

Both the control bit and meta bit attributes are preserved and respected by all other character and string functions, including code-char. They are not ignored by char-equal. Setting these bits are useful for creating characters not easily entered from the keyboard.

Similarity As Constants

The control bit and meta bit attributes are preserved in compiled-file literals. That is, two characters are not similar as constants if they have different attributes.

Readtables

Any character (not just simple characters) may have syntax in a readtable.

Parsing of Symbols By Read

The control bit and meta bit attributes are preserved when parsing a string into a symbol.

Parsing of Characters By Read

The following prefixes are recognized in the #\ syntax for characters: The case of prefixes is not important.

The behavior is undefined if the character following the prefix is not a base-char, or it already has the specified bit set.

Examples:

 (char= #\bell #\control-g #\CONTROL-G #\^g #\^G)
  => true
 (char= #\%g #\meta-g #\Meta-g)
  => true
 (char= #\%g #\%G)
  => nil
 (char= #\control-meta-g #\%^g)
  => true
 (char= #\line-feed #\control-j)
  => true
 (char= #\meta-null #\%^@ (code-char (1+ (char-code #\delete))))
  => true


Character Predicates and Case

The behavior of predicates such as graphic-char-p and upper-case-p, and case conversion operators such as char-downcase, depend on the operating system locale. Most operating systems will try to do the right thing for Latin characters if and only if the program uses the right locale. Eclipse effectively executes setlocale(LC_CTYPE, "") at start-up. Some operating systems do not do the right thing for Unicode characters which are not Latin.

Note that the Common Lisp string comparison functions (such as string-lessp) are defined to work character by character. This means that local collating conventions for text strings are not followed. However, the sense of case for each character is as for the character predicates.


Interaction With Streams

The following external-format designators are supported by open: Whether a Unicode character, or indeed, even a Latin or ASCII character is displayed "correctly" on a given stream, depends entirely on whether the external-format of the stream is correctly handled by the operating system. For example, if a Latin-char is written to an interactive :ASCII external-format stream, the correct ISO8859-1 glyph will be displayed only if the operating system supports ISO8859-1 for that stream.
[Previous] [Next] [Up] [Documentation Contents] [Eclipse Home Page]