Re: What's the correct way to deal with render_GET and unicode?

Phil Christensen <[email protected]>
Newsgroups gmane.comp.python.twisted.web
Message-ID <[email protected]>
On Aug 27, 2009, at 12:02 PM, Mark Wright wrote:
> If I return a unicode string from my Resource's render_GET, I get a
> 500 error that says "Request did not return a string".  I guess that
> means I'm responsible for encoding the response, but do I then need to
> write a render_HEAD to set the charset for the message?  Are there any
> examples of how to do this?

Assuming you're using Twisted.Web, you should just be able to set the  
encoding via the Request object, like:

	req.setHeader('Content-Type', 'text/html; charset=UTF-8')

-phil
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.