Take the 2-minute tour ×

In Common Lisp, I am writing a console application. I've finished most of the code, but two critical pieces are still confusing me.

  1. How to read a key from the input and get the ascii code for it.

  2. How to display an ascii character, without special formatting or newline.

On the second, I've tried:

(print (code-char 69))

Which displays:


But I just want it to display a plain:


On the first, I've had no luck at all.

If it helps, I am running clisp on Linux and OS X. Thanks!

share|improve this question
Common Lisp differentiates between the character and the encoding, fyi. #\E is the character. :-) –  Paul Nathan Dec 2 '10 at 21:18

2 Answers 2

up vote 7 down vote accepted

See read-char and write-char in the streams CLHS chapter. READ-CHAR reads a character. Portable Common Lisp does not have the capabilities to read 'keys', but it can read characters from a stream.

For getting the code of a character see char-code.

share|improve this answer
Thanks, things are working now! –  crc Nov 30 '10 at 21:13

to get a plain "E", execute

(princ (code-char 69))
share|improve this answer
Nice. This is shorter than what I did initially: (write-char (code-char 69) standard-output) –  crc Dec 1 '10 at 17:46

Your Answer


