0

有一个包含外语字符的 s 表达式文件,我正在阅读如下:

(defun test (file)
  (with-open-file (stream file)
    (loop while (read stream nil nil))))

它在 ccl 1.8 中读取文件没有错误,但在 1.9 下抛出错误:

? (test "/users/markklein/desktop/naples.text")
> Error: Reader error: Illegal symbol syntax.
> While executing: CCL::%PARSE-TOKEN, in process Listener(5).
> Type cmd-. to abort, cmd-\ for a list of available restarts.
> Type :? for other options.
1 > 

有谁知道出了什么问题,以及如何解决?我可以根据要求发送数据文件。

4

1 回答 1

2

Ben Hyde 在评论中指出,R. Matthew Emerson在 Clozure 邮件列表中谈到了这个问题,并指出 Clozure CL 的默认外部格式已更改为:utf-8. 因此,他提出了这个替代方案:

我们在 1.9 版本中将默认外部格式更改为 :utf-8。这可能会让你绊倒。尝试明确指定适当的外部格式,例如,

(defun test (file)
  (with-open-file (stream file :external-format :iso-8859-1)
    (loop while (read stream nil nil))))
于 2014-06-17T15:41:46.057 回答