Random Tech Thoughts

The title above is not random

SLIME & Encoding

While I was experimenting “cating” a file in Common Lisp, I found that SLIME will report lost connection once I read an UTF-8 encoded file. For plain ascii file, however, there’s no problem. I tried to run the program directly in SBCL, it also worked fine. So I was sure that this problem was caused by SLIME.

After Googleing for a while, I came to this soluiton. Just put this in your .emacs file.

(require 'slime)
(setq slime-net-coding-system 'utf-8-unix) ; Add this line.

The setq tells SLIME to use the specified encoding. And now reading UTF-8 encoded file has no problem, and you can also input Chinese characters into SLIME.

For more information, follow this thread in the slime-devel mailing list.