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
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
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
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.
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.
·············@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__