[Lispweb] Stream encoding question
Richard Newman
r.newman at reading.ac.uk
Sat Sep 30 15:00:19 CDT 2006
You might have some luck changing compat/compat-sbcl.lisp:
(in-package :araneida)
(defparameter *open-external-format-arguments*
'(:element-type (unsigned-byte 8) :external-format :iso-8859-1))
Look through that file, and try it if you change the :external-
formats to a Unicode version. Also make sure that your SBCL is
Unicode-enabled (it should be).
The easier alternative is to escape all non-latin characters; ©,
™, and so on. If you want to preserve XML-ness, rather than
using HTML entities, then use their numeric versions.
-R
On 30 Sep 2006, at 5:26 PM, Jonathon McKitrick wrote:
>
> Is there a way to set the encoding for the stream used to serve
> files in
> araneida? I *think* that's what I'm asking, but I'm not sure.
>
> I have an html file with a few non-latin-1 characters - copyright,
> TM, a
> bullet, etc. Serving them as static files works fine, but when I use
> html-template to serve the file, it signals a condition:
>
> encoding error on stream #<SB-SYS:FD-STREAM for "a constant string"
> {128ACFB1}>
> (:EXTERNAL-FORMAT :LATIN-1):
> the character with code 8226 cannot be encoded.
> [Condition of type SB-INT:STREAM-ENCODING-ERROR]
>
> Restarts:
> 0: [OUTPUT-NOTHING] Skip output of this character.
> 1: [ABORT-RESPONSE] Abort this response and answer another request
> 2: [ABORT] Exit debugger, returning to top level.
>
> Backtrace:
> 0: (SB-INT:STREAM-ENCODING-ERROR #<SB-SYS:FD-STREAM for "a
> constant
> string" {128ACFB1}> 8226)
> 1: (SB-IMPL::STREAM-ENCODING-ERROR-AND-HANDLE #<SB-SYS:FD-
> STREAM for
> "a constant string" {128ACFB1}> 8226)
> 2: (SB-IMPL::OUTPUT-BYTES/LATIN-1 #<SB-SYS:FD-STREAM for "a
> constant
> string" {128ACFB1}> "<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML
> 4.01//EN\"
> \"http://www.w3.org/TR/html4/strict.dtd\">
>
> --- html snipped ---
>
> <div class=\"comment\">
> Copyright (c) 2006 Reed Larkey Group Inc. ? Website
> designed by
> <a href=\"http://www.bartosz.co.nr/\">Bartosz Brzezinski</a>
> </div>
>
> </div><!-- container -->
> </body>
>
> </html>
> " #<SB-SYS:FD-STREAM for "a constant string" {128ACFB1}> :START 0
> :END NIL)
> 6: ((LAMBDA (VALUES)) NIL)
> 7: ((SB-PCL::FAST-METHOD HTML-TEMPLATE:FILL-AND-PRINT-TEMPLATE
> (PATHNAME T)) #<unavailable argument> #<unavailable argument>
> #P"web/am01/index.html" NIL (:STREAM #<SB-SYS:FD-STREAM for "a
> constant string" {128ACFB1}>))
>
>
> Changing EXTERNAL-FORMAT for HTML-TEMPLATE doesn't change
> anything. It still
> shows up as LATIN-1 when served through araneida. Calling HTML-
> TEMPLATE alone
> in SLIME sends the file in question to the output buffer with no
> problem.
>
> You can see it is the same stream being used by html-template and
> araneida,
> but araneida does not handle the non-latin-1 characters in this
> instance,
> though it can serve the file directly w/o a template with no problem.
>
> Jonathon McKitrick
> --
> My other computer is your Windows box.
>
> _______________________________________________
> lispweb mailing list
> lispweb at red-bean.com
> http://www.red-bean.com/mailman/listinfo/lispweb
More information about the lispweb
mailing list