如何在Lisp(sbcl + slime)中打开一个包含Unicode代码的文件?

问题描述 投票:4回答:1
(with-open-file (s "~/例子.txt"
                 :external-format :utf-8)
  (print s))

结果:

NIL c-string encoding error:
  the character with code 20363 cannot be encoded.
  [Condition of type SB-INT:C-STRING-ENCODING-ERROR]

示例:

在带有最新粘液和sbcl2.0.2的Aquamacs 3.5中:in Aquamacs3.5 with slime & sbcl

iterm2中的sbcl可以做到:

in iterm2

Aquamacs本身也可以正确打开和写入包含utf-8的文件名。

我尝试添加

(setq slime-net-coding-system 'utf-8-unix)
(set-language-environment "UTF-8")

在我的aquamacs配置文件中,但不起作用。请帮助!

更新:我终于找到了原因。在Iterm2中时,命令

locale

提供以下输出:enter image description here

虽然在Aquamacs中从ui打开,但在eshell中它给出了:

Result from eshell

添加后:

(setenv "LANG" "en_US.UTF-8")

对于我的Aquamacs配置,它可以正常工作!感谢所有回答我的问题的人!以下是对我有帮助的链接。

What the question exactly is

Resolutions to the question

How to set locale for Emacs open from UI

unicode utf-8 common-lisp filenames slime
1个回答
0
投票

添加类似内容:

© www.soinside.com 2019 - 2024. All rights reserved.