[Zope] force the output encoding to utf-8 in page templates
Yuri
yurj at alfa.it
Fri Nov 11 11:56:30 UTC 2011
Il 11/11/2011 12:43, Yuri ha scritto:
> Hi all!
>
> I've a Zope2 application with Postgresql. All is ok and utf-8 but
> page templates. This means that non utf-8 data is sent to the
> database, and the database complain with:
>
> *Error Type: DataError*
> *Error Value: invalid byte sequence for encoding "UTF8": 0xe82527
> HINT: This error can also happen if the byte sequence does not match
> the encoding expected by the server, which is controlled by
> "client_encoding".
>
> *This does not happen if I manually switch the browser encoding
> (Firefox -> View -> character encoding -> Unicode (UTF-8)) and submit
> a form.
>
> So my question is: how do I tell to page templates to output utf-8
> instead of iso8859-15? The output_encoding property does anything.
>
> Obviously, changing default-zpublisher-encoding to utf-8 works, but
> other legacy applications will have problems on characted encoding.
>
> Any idea?
> **
I've solved in page templates code:
if not response.headers.has_key('content-type'):
response.setHeader('content-type', self.content_type +
';charset=' + self.output_encoding) <- here add the utf-8, the
publisher will find this filled and avoid to put the default.
on line 315 of ZopePageTemplate.py
Is there a better way? Thanks!
More information about the Zope
mailing list