Character encoding 关于使用PortableAllegroServe进行字符编码

Character encoding 关于使用PortableAllegroServe进行字符编码,character-encoding,internationalization,common-lisp,httpserver,Character Encoding,Internationalization,Common Lisp,Httpserver,我正在archlinux和PortableServe上使用sbcl(1.1.15)编写一个web应用程序。但是我在使用“我的”这样的角色时遇到了一些麻烦测试". REPL仅打印错误:获取错误值30334不是类型(无符号字节8)。 浏览器什么也不显示 这是我的密码: (defpackage #:com.web (:use :common-lisp :net.aserve)) (in-package :com.web) (defun test-character-encode (req e

我正在archlinux和PortableServe上使用sbcl(1.1.15)编写一个web应用程序。但是我在使用“我的”这样的角色时遇到了一些麻烦测试".

REPL仅打印错误:获取错误值30334不是类型(无符号字节8)。 浏览器什么也不显示

这是我的密码:

(defpackage #:com.web
  (:use :common-lisp :net.aserve))

(in-package :com.web)

(defun test-character-encode (req ent)
  (with-http-response (req ent :content-type "text/html")
    (with-http-body (req ent)
      (format
        (request-reply-stream req)
        "测试portableallegroserve"))))

(publish :path "/test" :function 'test-character-encode)

我该怎么做,谢谢!

带有http body的
文档描述了一个
:外部格式
参数,您可能需要指定该参数:

在主体内形成代码调用(请求-应答流req)以 获取它可以写入的流,以提供 响应。此流的外部格式设置为 外部格式参数(默认为 *默认的aserve外部格式*)。变量*html stream*绑定到(request-reply stream-req)的值,然后返回正文 这使得使用html宏生成 html作为响应的一部分

基于这一点,也许你需要

(with-http-body (req ent :external-format :utf-8) 
  (format
    (request-reply-stream req)
    "测试portableallegroserve"))))

如果可以,请不要忘记相应地设置内容类型:
:Content Type“text/html;charset=UTF-8“
它不工作,REPL打印相同的错误消息。我使用(net.aserve.client:do http request)访问端口1234处的本地主机。它向我显示了错误消息:读取chunk block[Condition of type SIMPLE-error]时出现意外的文件结尾。您是否也按照另一条注释的建议添加了content type:header?是的,我添加了关键字::content type“text/html;charset=UTF-8”。如果我格式化字符串“abc测试“定义”到浏览器,只有“abc”可以显示在汉字前。
(with-http-body (req ent :external-format :utf-8) 
  (format
    (request-reply-stream req)
    "测试portableallegroserve"))))