cl-closure-template 中文乱码的解决方法

最近一直在学习用cl-closure-template处理模版,发现一个问题,当把模版函数保存在一个文件中,使用文件路径编译时,模版函数中的中文字符变为乱码,这个是cl-closure-template读取文件时使用了系统默认编码方式导致的(alexandria:read-file-into-string obj),要解决此问题,可以在cl-closure-template模块的src/parser/command.lisp的函数parse-template中加入指定编码方式的语句(红色部分):

(defun parse-template (obj)
(closure-template-parse 'namespace
(typecase obj
(string obj)
(pathname (alexandria:read-file-into-string obj :external-format :utf-8)))))

问题便可解决。

posted @ 2014-02-16 22:13  误会僧  阅读(408)  评论(0编辑  收藏  举报