logo       
Google Custom Search
    AddThis Social Bookmark Button
-->

Re: Recap on utf8 encoding issues and PerlIO patch: msg#00058

Subject: Re: Recap on utf8 encoding issues and PerlIO patch
> > (after eliminating the issue of the browser trying to display utf8
> > as Western ISO-8859-1)
> 
> We have discovered that browsers sometimes do this even when
> presented with all the right hints.  We currently put this <snip>

To add another tip to the bucket, I've discovered that even though I
have Apache setup with 'AddDefaultCharset utf-8', I would get
dynamically generated webpages coming through with the charset set to
ISO-8859-1. It turns out that if you are using CGI.pm to create queries,
it automatically defaults to this charset (aka, latin1).

This situation leads to a couple of options when using Petal with
CGI.pm:

  a) Always specify the charset as utf-8 when creating your CGI object.
  For example:
  
      my $q = CGI->new;
      print $q->header(-charset => 'utf-8');
      # carry on with your Petal processing...

  b) Always re-encode the string returned from Petal's process() method
  into latin1 format. For example:

      my $template = Petal->new('template.tmpl');
      my $html = $template->process({ 'foo' => 'bar'});
      print "Content-type: text/html\n\n";
      print Encode::encode('latin1', $html);


Cheers!
William

-- 
Knowmad Services Inc.
http://www.knowmad.com



<Prev in Thread] Current Thread [Next in Thread>