[cgiapp] Problem displaying French, sometimes

Peter Karman peter at peknet.com
Sat Sep 6 21:49:22 EDT 2008


Ron Savage wrote on 9/5/08 7:51 PM:
> Hi Folks
> 
> Here is the set up (details below):
> o An fcgid scripts calls...
> o A module based on CGI::Application::Dispatch, which calls...
> o My module, which reads country names from Postgres and displays them
> 
> This works, so Ivory Coast is displayed as 'CÔte D'ivoire' (ignoring the
> upper-case O with caret for the moment).
> 
> But when the first module above is installed as a mod_perl handler,
> and /that/ calls my module, the output is 'CÔte D'ivoire'.
> 
> I find this scary, and would love an explanantion.
> 

Sounds like a typical encoding issue. The 'bad' display above is likely because
you are sending utf8 encoded strings to the browser but claim that the charset
is latin1.

IMO, the best route is all utf8, all the time. Store strings encoded as utf8 in
your db, send utf8 to the browser, and encode/decode at your program boundaries.
It's a real b*tch to track down the problem spots in a multiple-encoding set up.
That's why I wrote Search::Tools::UTF8 to help me. If I'm having trouble, I
usually throw a to_utf8() function call at suspect strings and make sure I
declare utf8 as my charset in all my http headers and output.


-- 
Peter Karman  .  http://peknet.com/  .  peter at peknet.com


More information about the cgiapp mailing list