From: gnp
Subject: create a character or string from a character code
Date: 
Message-ID: <1131821825.277127.75210@g47g2000cwa.googlegroups.com>
I know I can use char-code to get the character code of a character.
How can I do the opposite, i.e. give a character code and get a
character from lisp?

Sorry if this is a trivial question, but I am new to Lisp, and I have
not managed to find something useful in the on-line version of cltl2,
or in Paul Graham's "ANSI Common Lisp".

I just want to construct a string containing all the graphical
characters of Lisp, and I assume that I can do that by looping through
the character codes and getting the corresponding characters. That's
why I'm asking. Or is there another way to construct the string?

-- gnp

From: Tayssir John Gabbour
Subject: Re: create a character or string from a character code
Date: 
Message-ID: <1131822553.482568.117840@g49g2000cwa.googlegroups.com>
gnp wrote:
> I know I can use char-code to get the character code of a character.
> How can I do the opposite, i.e. give a character code and get a
> character from lisp?
>
> Sorry if this is a trivial question, but I am new to Lisp, and I have
> not managed to find something useful in the on-line version of cltl2,
> or in Paul Graham's "ANSI Common Lisp".
>
> I just want to construct a string containing all the graphical
> characters of Lisp, and I assume that I can do that by looping through
> the character codes and getting the corresponding characters. That's
> why I'm asking. Or is there another way to construct the string?
>
> -- gnp

You may feel bad once I tell you...

CL-USER> (code-char 10)
#\Newline

But who cares? ;)

Tayssir
From: M Jared Finder
Subject: Re: create a character or string from a character code
Date: 
Message-ID: <WrudndUkk4JC3-veRVn-qg@speakeasy.net>
gnp wrote:
> I know I can use char-code to get the character code of a character.
> How can I do the opposite, i.e. give a character code and get a
> character from lisp?
> 
> Sorry if this is a trivial question, but I am new to Lisp, and I have
> not managed to find something useful in the on-line version of cltl2,
> or in Paul Graham's "ANSI Common Lisp".
> 
> I just want to construct a string containing all the graphical
> characters of Lisp, and I assume that I can do that by looping through
> the character codes and getting the corresponding characters. That's
> why I'm asking. Or is there another way to construct the string?

The function you want is code-char.

But watch out!  The string you want to print will be 1114046 chars long 
(on SBCL), so you might end up waiting a while for the REPL to print 
such a string.

   -- MJF
From: Pascal Bourguignon
Subject: Re: create a character or string from a character code
Date: 
Message-ID: <87iruxn0oo.fsf@thalassa.informatimago.com>
"gnp" <·······@gmail.com> writes:

> I know I can use char-code to get the character code of a character.
> How can I do the opposite, i.e. give a character code and get a
> character from lisp?
>
> Sorry if this is a trivial question, but I am new to Lisp, and I have
> not managed to find something useful in the on-line version of cltl2,
> or in Paul Graham's "ANSI Common Lisp".

The reference is the HyperSpec, aka CLHS: 
http://www.lispworks.com/documentation/HyperSpec/


> I just want to construct a string containing all the graphical
> characters of Lisp, and I assume that I can do that by looping through
> the character codes and getting the corresponding characters. That's
> why I'm asking. Or is there another way to construct the string?

You may want to read the Chapters about Characters and Strings.

But are you sure to want to build such a string?  On clisp:

(loop :for c :below CHAR-CODE-LIMIT
      :when (graphic-char-p (code-char c)) :count 1) --> 232624

-- 
__Pascal Bourguignon__                     http://www.informatimago.com/

In a World without Walls and Fences, 
who needs Windows and Gates?