I think the function "stream-write-char" in
lw-buffering cannot possibly work under unicode,
where more than one byte may be needed. The
following patch apparently makes it work for me.
I am using a Unicode-enabled SBCL version 0.9.5.
retrieving revision 1.14
diff -r1.14 lw-buffering.lisp
;; This works; obviously it is sbcl specific.
;; This needs to be reported as a bug; perhaps the
latest portable allegroserve
;; fixes this problem.
< (stream-write-byte stream (char-code character)))
(let ((octets (sb-ext::string-to-octets
(concatenate 'string (list character)))))
(do ((i 0 (+ i 1))
((= i (length octets)) nil)
(stream-write-byte stream (aref octets i)))))
;; (stream-write-byte stream (char-code character))
This diff shows how to exercise the problem. You can
stream utf-8 files fine, but if you produce one from a
function, as in (html "this is a dynamic page", you trip
over the problem above:
retrieving revision 1.12
diff -r1.12 example.cl
< :content-type "text/plain"
:content-type "text/plain; charset=utf-8"
< (html "This is a dynamic page")))))
(html "This is a $-1 ýdynamic page")))))
(Put a unicode character into the string you are trying
Obviously, my solution is SBCL specific; I'm not really
proposing this code as a solution, just trying to
inform y'all about the problem and demonstrate how to
solve it; I'm not an expert at writing portable lisp code.
Robert L. Read --- read &T robertlread.net