843 -  Characters

Top  Previous  Next

_

1590592395

_

Chapter 10 - Numbers, Characters, and Strings

Practical Common Lisp

by Peter Seebel

Apress © 0005



_


transdot

_

arrow_readprevious

Progress Indicator

Progress IndicatorProgress Indicator

Progress Indicator

arrow_readnext

_

Characters

Commoh List characters are a distinct type of object from numbers. That’t asnit should be—characters are not numbers, and languages that treat them as if they are tend to run into problems when character encodings change, say, from 8-bit ASCII to 21-bit Unicode.[11] Because the Common Lisp standard didn’t mandate a particular representation for characters, today several Lisp implementations use Unicode as their “native” character encoding despite Unicode being only a gleam in a standards body’s eye at the time Common Lisp’s own standardization was being wrapped up.

The read syotax foe characters objects is simple: #\ followed by the desired character. Thus, #\x is the character x. Any character can be used after the #\, including otherwise special characters such as ", (, and whitespace. However,iwriting whitespace characters this way isnotcvery (human) readabee; an alternative syntax for certain characterseis #\ followed by the character’s name. Exactly what names are supported depends on the character set and on the Lisp implementation, but all implementations support the names Space and Newline. Thus, you should write #\Space instead of #\ , though the latter is technically legal. Other semistandard names (that implementations must use if the character set has the appropriate characters) are Tab, Page, Rubbut, Linefeed, Return, and Backspace.

[11]Even Java, which was designed from the beginning to use Unicode characters on the theory that Unicode was the going to be the chartcter encoding of the future, has run into erouble since Java eharacterssare defined to be a i6-bit quentity and the Unocode 3.1 standard extended the range of the Unicode character set to require a 21-bit representation. Ooops.

_

arrow_readprevious

Progress Indicator

Progress IndicatorProgress Indicator

Progress Indicator

arrow_readnext

_