Re: Problem with the function "character"

Edi Weitz <[email protected]> 27 Aug 2003 17:53:23 +0200
Newsgroups gmane.lisp.corman
Message-ID <[email protected]>
On Wed, 27 Aug 2003 17:07:42 +0200, Norbert Lehmann <[email protected]> wrote:

> how can I obtain for a ASCII code the corresponding character ?
> Usually, I used the function "character" for this purpose. For
> example (in CLisp, but also in Macintosh Common Lisp)
> 
>   [1]> (character 97)
>   #\a

Not for me (CLISP 2.30 on Linux):

  edi@bird:~ > clisp
    i i i i i i i       ooooo    o        ooooooo   ooooo   ooooo
    I I I I I I I      8     8   8           8     8     o  8    8
    I  \ `+' /  I      8         8           8     8        8    8
     \  `-+-'  /       8         8           8      ooooo   8oooo
      `-__|__-'        8         8           8           8  8
          |            8     o   8           8     o     8  8
    ------+------       ooooo    8oooooo  ooo8ooo   ooooo   8

  Copyright (c) Bruno Haible, Michael Stoll 1992, 1993
  Copyright (c) Bruno Haible, Marcus Daniels 1994-1997
  Copyright (c) Bruno Haible, Pierpaolo Bernardi, Sam Steingold 1998
  Copyright (c) Bruno Haible, Sam Steingold 1999-2002

  [1]> (character 97)

  *** - CHARACTER: cannot coerce 97 to a character

The function CHARACTER only accepts "character designators" as
arguments - these are either characters or designators for strings of
length one.

> where 97 is the ASCII code for the lower A. Unfortunately, in Corman
> Lisp, I obtain the error message "The object 97 cannot be coerced to
> a character". Equivalently, using "coerce", the same error message
> is obtained in Corman Lisp.

The ASCII standard defines the function CODE-CHAR which does what you
want. Should work in all conforming implementations.

Edi.

------------------------ Yahoo! Groups Sponsor ---------------------~-->
Buy Ink Cartridges or Refill Kits for Your HP, Epson, Canon or Lexmark
Printer at Myinks.com. Free s/h on orders $50 or more to the US & Canada. http://www.c1tracking.com/l.asp?cid=5511
http://us.click.yahoo.com/l.m7sD/LIdGAA/qnsNAA/SyjtlB/TM
---------------------------------------------------------------------~->

To unsubscribe from this group, send an email to:
[email protected]

 

Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/