From: ·············@gmail.com
Subject: Printing unicode
Date: 
Message-ID: <344b5e05-57dd-40ac-900c-332eb7c82d93@w24g2000prd.googlegroups.com>
Hi all,

I'm just starting out with Lisp, and I'm trying to print some unicode
characters in the REPL. I'm using LispBox for windows. (CLISP 2.33)

When I do this:

(format t "~a" (code-char #x9824))

I get the error:

Character #\u9824 cannot be represented in the character set
CHARSET:ISO-8859-1

x9824 is ¢¼, the unicode character for BLACK SPADE SUIT. I'm guessing
something expects output to be in ISO-8859-1, and that I need to
change that to utf-8? How can I do that?

I tried this:

(setf CUSTOM:*TERMINAL-ENCODING* (make-encoding :charset
charset:utf-8 :line-terminator :dos))

But that gave this error:

SYSTEM::SET-STREAM-EXTERNAL-FORMAT on #<IO TWO-WAY-STREAM
  #<SWANK-BACKEND::SLIME-INPUT-STREAM #x19EED875>
  #<IO UNBUFFERED SOCKET-STREAM CHARACTER 0.0.0.0:2757>> is illegal
   [Condition of type SYSTEM::SIMPLE-STREAM-ERROR]

Have anyone encountered anything similiar?

Thanks in advance,
Jens

From: smallpond
Subject: Re: Printing unicode
Date: 
Message-ID: <64a50819-66a4-47de-9147-7407519d947b@p35g2000prm.googlegroups.com>
On Nov 8, 4:32 pm, ·············@gmail.com wrote:
> Hi all,
>
> I'm just starting out with Lisp, and I'm trying to print some unicode
> characters in the REPL. I'm using LispBox for windows. (CLISP 2.33)
>
> When I do this:
>
> (format t "~a" (code-char #x9824))
>
> I get the error:
>
> Character #\u9824 cannot be represented in the character set
> CHARSET:ISO-8859-1
>
> x9824 is ¢¼, the unicode character for BLACK SPADE SUIT. I'm guessing
> something expects output to be in ISO-8859-1, and that I need to
> change that to utf-8? How can I do that?
>
> I tried this:
>
> (setf CUSTOM:*TERMINAL-ENCODING* (make-encoding :charset
> charset:utf-8 :line-terminator :dos))
>
> But that gave this error:
>
> SYSTEM::SET-STREAM-EXTERNAL-FORMAT on #<IO TWO-WAY-STREAM
>   #<SWANK-BACKEND::SLIME-INPUT-STREAM #x19EED875>
>   #<IO UNBUFFERED SOCKET-STREAM CHARACTER 0.0.0.0:2757>> is illegal
>    [Condition of type SYSTEM::SIMPLE-STREAM-ERROR]
>
> Have anyone encountered anything similiar?
>
> Thanks in advance,
> Jens


(format t "~a" (code-char 9824))
*** - Character #\u2660 cannot be represented in the character set
CHARSET:ISO-8859-1

(format t ··@C" (code-char 9824))
#\BLACK_SPADE_SUIT

The US DOS character set is CP437, which lists the spade character
as Unicode value dec 9824 / hex 2660. It does not appear in either
Latin-1 (8859-1) or Windows Latin-1 (CP1252).
W3C.org has 2660 in the ISOPUB set, whatever that means.

http://en.wikipedia.org/wiki/CP437
http://www.w3.org/TR/2008/WD-xml-entity-names-20080721/isopub.html
From: ·············@gmail.com
Subject: Re: Printing unicode
Date: 
Message-ID: <c5799911-e297-4ff8-ae9e-231197b27fe3@o4g2000pra.googlegroups.com>
On Nov 9, 5:42 pm, smallpond <·········@juno.com> wrote:
> The US DOS character set is CP437, which lists the spade character
> as Unicode value dec 9824 / hex 2660.

Seems I got my decimal and hex mixed up there:)
But I still get the same message:

Character #\u2660 cannot be represented in the character set
CHARSET:ISO-8859-1
From: Alex Mizrahi
Subject: Re: Printing unicode
Date: 
Message-ID: <49171db7$0$90265$14726298@news.sunsite.dk>
 j> x9824 is ��, the unicode character for BLACK SPADE SUIT. I'm guessing
 j> something expects output to be in ISO-8859-1, and that I need to
 j> change that to utf-8? How can I do that?

as far as i understand it is not that simple -- you can change the way
how CLISP translates characters to bytes, but underlying Windows API
still will require a specific charset, so that won't work.

just as an idea, you might have better luck if you use Emacs/SLIME
for output. 
From: ·············@gmail.com
Subject: Re: Printing unicode
Date: 
Message-ID: <2e0d9002-f4ec-4536-a67a-6b1fc01e4944@a3g2000prm.googlegroups.com>
On Nov 9, 6:28 pm, "Alex Mizrahi" <········@users.sourceforge.net>
wrote:
> just as an idea, you might have better luck if you use Emacs/SLIME
> for output.

Ah, but I do! I should have made that clear. I am getting this in
Emacs + SLIME.
From: Pascal J. Bourguignon
Subject: Re: Printing unicode
Date: 
Message-ID: <7c8wrrkj96.fsf@pbourguignon.anevia.com>
·············@gmail.com writes:

> Hi all,
>
> I'm just starting out with Lisp, and I'm trying to print some unicode
> characters in the REPL. I'm using LispBox for windows. (CLISP 2.33)
>
> When I do this:
>
> (format t "~a" (code-char #x9824))
>
> I get the error:
>
> Character #\u9824 cannot be represented in the character set
> CHARSET:ISO-8859-1
>
> x9824 is ♠, the unicode character for BLACK SPADE SUIT. I'm guessing
> something expects output to be in ISO-8859-1, and that I need to
> change that to utf-8? How can I do that?
>
> I tried this:
>
> (setf CUSTOM:*TERMINAL-ENCODING* (make-encoding :charset
> charset:utf-8 :line-terminator :dos))
>
> But that gave this error:
>
> SYSTEM::SET-STREAM-EXTERNAL-FORMAT on #<IO TWO-WAY-STREAM
>   #<SWANK-BACKEND::SLIME-INPUT-STREAM #x19EED875>
>   #<IO UNBUFFERED SOCKET-STREAM CHARACTER 0.0.0.0:2757>> is illegal
>    [Condition of type SYSTEM::SIMPLE-STREAM-ERROR]
>
> Have anyone encountered anything similiar?

The problem you have is that slime sets up in the inferior lisp the
streams as a compound stream, and the encoding cannot be changed on
this compound stream.

You could try to change the external-format on each of the streams in
the compound stream (a two-way-stream in this case).

Or you could set slime so that it launches clisp with the right
encoding on both sides.


Perhaps something like the following in ~/.emacs would help:

(setf slime-net-coding-system 'utf-8-unix)
(setf inferior-lisp-program "/usr/bin/clisp -ansi -q -K full -m 32M -I -E UTF-8 -Epathname ISO-8859-1 -Eforeign ISO-8859-1")

which is what I have.


When you M-x slime, check that the first line in *inferior-lisp*
mentions :utf-8-unix as:

(progn (load "/usr/share/emacs/site-lisp/slime/swank-loader.lisp" :verbose t) (funcall (read-from-string "swank:start-server") "/tmp/slime.5749" :external-format :utf-8-unix))


Then:

;; Loading file /usr/share/emacs/site-lisp/slime/swank-version.el ...
;; Loaded file /usr/share/emacs/site-lisp/slime/swank-version.el
CL-USER> 
CL-USER> *terminal-io*
#<IO TWO-WAY-STREAM #<SWANK-BACKEND::SLIME-INPUT-STREAM #x000334225CC8> #<SWANK-BACKEND::SLIME-OUTPUT-STREAM #x000334223CD0>>
CL-USER> custom:*terminal-encoding*
#<ENCODING CHARSET:UTF-8 :UNIX>
CL-USER> 


-- 
__Pascal Bourguignon__