Re: [cgiapp] UTF-8 output

2009-11-02 Thread Michael Peters
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.

 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.

-- 
Michael Peters
Plus Three, LP

#  CGI::Application community mailing list  
####
##  To unsubscribe, or change your message delivery options,  ##
##  visit:  http://www.erlbaum.net/mailman/listinfo/cgiapp##
####
##  Web archive:   http://www.erlbaum.net/pipermail/cgiapp/   ##
##  Wiki:  http://cgiapp.erlbaum.net/ ##
####




Re: [cgiapp] UTF-8 output

2009-11-02 Thread Michael Lackhoff
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


#  CGI::Application community mailing list  
####
##  To unsubscribe, or change your message delivery options,  ##
##  visit:  http://www.erlbaum.net/mailman/listinfo/cgiapp##
####
##  Web archive:   http://www.erlbaum.net/pipermail/cgiapp/   ##
##  Wiki:  http://cgiapp.erlbaum.net/ ##
####




Re: [cgiapp] UTF-8 output

2009-11-02 Thread Michael Lackhoff
On 02.11.2009 16:21 Emmanuel Seyman wrote:

From CGI.pm :
 
 # set charset to the safe ISO-8859-1
 $self-charset('ISO-8859-1');
 
 http://cpansearch.perl.org/src/LDS/CGI.pm-3.48/lib/CGI.pm

Thanks for the hint! But isn't it better then to tackle the problem
right at the root:
$webapp-query-charset('UTF-8'); # works!

 I always add the following line :
 
 $webapp-header_add(-charset = 'UTF-8');

because this would set the header twice, first from CGI.pm to ISO-8859-1
then from the webapp to UTF-8 (no big deal but still) or are there other
reasons why header_add is better?

But since this is more or less academic because both approaches work, I
would be much more interested in good ways to deal with the decoding of
CGI-params and the encoding of TT-templates ;-)

-Michael

#  CGI::Application community mailing list  
####
##  To unsubscribe, or change your message delivery options,  ##
##  visit:  http://www.erlbaum.net/mailman/listinfo/cgiapp##
####
##  Web archive:   http://www.erlbaum.net/pipermail/cgiapp/   ##
##  Wiki:  http://cgiapp.erlbaum.net/ ##
####




Re: [cgiapp] UTF-8 output

2009-11-02 Thread Cees Hek
On Tue, Nov 3, 2009 at 3:23 AM, Michael Lackhoff
lackh...@zbmed.uni-koeln.de wrote:
 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).

Have a look at this perlmonks post by Rhesa:

http://www.perlmonks.org/?node_id=651574

Cheers,

Cees

#  CGI::Application community mailing list  
####
##  To unsubscribe, or change your message delivery options,  ##
##  visit:  http://www.erlbaum.net/mailman/listinfo/cgiapp##
####
##  Web archive:   http://www.erlbaum.net/pipermail/cgiapp/   ##
##  Wiki:  http://cgiapp.erlbaum.net/ ##
####