[cgiapp] UTF-8 output

Michael Lackhoff lackhoff at zbmed.uni-koeln.de
Mon Nov 2 11:23:14 EST 2009


On 02.11.2009 15:27 Michael Peters wrote:

> On 11/02/2009 12:43 AM, Michael Lackhoff wrote:
> 
>> Without the header_add I get
>> a HTTP header with an ISO-8859-1 charset definition so the browser
>> thinks it is latin1 and even a
>> <meta http-equiv="content-type" content="text/html; charset=UTF-8" />
>> in the template won't help.
> 
> That's very strange. Does it happen the same across all browsers? The 
> <meta> tag should be equivalent to the HTTP header.

It is with firefox, the only relevant browser for my app. If they are
equivalent it might be undefined who wins: the HTTP header or the
meta-tag. But I will do more tests with a very basic template.

>> And is there no better way for the template output than to post_process
>> the whole template? Is there no way to get the output of tt_process as
>> UTF-8 so that there is no post_processing necessary?
> 
> I have a patched HTML::Template that reads in the templates as UTF8, my 
> db connections are all UTF8 and I decode the CGI params as UTF8. As long 
> as all your inputs are UTF8 decoded then you don't need to explicitly 
> encode the output.

Sounds very interesting. Let me try to follow:
I am in the process of changing the db connection as well but have still
some problems with CGI params. How do you decode them? Not one at a
time, I guess? In my app they seem to be encoded twice after a roundtrip
(have to do more debugging).
Say, I managed to have all my inputs UTF8 decoded, how do you persuade
Perl to output UTF8 without explicit encoding? Is it just your patched
HTML::Template or is there a trick that would also work with
Template::Toolkit?

Many thanks for your response!
-Michael



More information about the cgiapp mailing list