Re: twisted.web.template output encoding

Phil Mayers <[email protected]>
Newsgroups gmane.comp.python.twisted.web
Message-ID <[email protected]>
On 11/26/2011 04:52 PM, [email protected] wrote:

> as `&nbsp;�. Consequently, callers of `formatFailure� will probably
> mishandle the result - the caller in `twisted.web.server� does, at
> least, including the bytes in a page with a content type of "text/html".

Amusingly for a unicode-related email, Thunderbird mangled your 
close-quotes for me ;o)

> One solution is to add support for named entities or numeric character
> references to twisted.web.template. Very likely this is a good idea
> regardless (Nevow supported these).

Always useful.


> Perhaps another question is whether the encoding used by
> `twisted.web.template� should be a parameter. A related question raised
> might be whether `twisted.web.template� should encoded to bytes at all,
> or delegate the responsibility for that to code closer to a socket.

FWIW that would be my instinct. If t.w.template emitted unicode, then 
code closer to the socket could decide on the encoding. Presumably the 
default would be to encode to utf-8, but there are cases where you might 
want to do otherwise e.g. some HTML has already been streamed to the 
client with no encoding specified - which equates to iso-8859-1 IIRC? - 
and you want to match that.

Conceptually, HTML is better treated as unicode too.

_______________________________________________
Twisted-web mailing list
[email protected]
http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-web
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.