[Catalyst] mod_perl converts latin1 to utf8 !?

Bjørn-Helge Mevik bhx6 at mevik.net
Sun Dec 21 22:52:27 GMT 2008


I'm a new Catalyst user and this is my first Catalyst project, so
please forgive my ignorance.

I am developing a simple Catalyst application using MySQL, FormFu and
TT.  I have everything encoded in ISO-8859-1: the data in MySQL, the
Perl files, the FormFu .yml files, and the TT templates.  (I am even
running in a ISO-8859-1 locale, for what it's worth.)

Following the advice in an earlier thread ("Charset best practice" - 
<http://www.mail-archive.com/catalyst@lists.scsys.co.uk/msg00284.html>),
I have overridden the process() method of Catalyst::View::TT with a
version that does $c->response->content_type('text/html;
charset=iso-8859-1');

Running under the test server (myapp_server.pl), everything works
perfectly.  Non-ASCII characters (like æøå) are displayed correctly,
and they end up stored correctly in MySQL if I enter them in forms.

But under mod_perl, characters are displayed as their 2 byte UTF-8
encoding (for instance 'æ' becomes 'æ'), and values entered in forms
are stored in MySQL that way - and are "doubly" UTF-8 encoded when
they are displayed in the browser again.

Without the modified process() method, non-ASCII characters are displayed
correctly initially under mod_perl, but characters entered in forms
are still stored in MySQL as UTF-8, and are shown that way when
displayed in the browser again.

Thus it would seem that mod_perl converts latin1 to utf8 when sending
to the browser, but not back again when receiving forms.

(Under the test server, without the modified process(), non-ASCII
characters are displayed as invalid characters.  This is natural,
since we are telling the browser that the document is UTF-8 encoded,
while sending it ISO-8859-1 characters.)

What can I do about this?  Can I tell mod_perl to "leave my characters
alone"?  Have I made an error somewhere?

-- 
Regards,
Bjørn-Helge Mevik



More information about the Catalyst mailing list