libintl-perl

Home -> libintl-perl -> 2005 -> September

 Weird character set problem 
Login Login Subscribe Subscribe  Date  09/01/05 13:54:19 GMT
 From  Robin Smidsrød
 Subject  Weird character set problem
 Previous Thread
 Next Thread
 Start of Thread
 Reference
 Previous Reply
 This Message
 Reply
 Next Reply
> I would recommend to use utf-8 in your web application.  But you have to
> make sure that you really generate utf-8 strings _and_ that your web server
> issues a header with the correct encoding:
>
> Content-Type: text/html; charset=utf-8
>
> You can check that with the option "--save-headers" from wget, and also in
> most browsers (for example in Mozilla try View->Character Encoding).
>
> I suspect that your web server does not respond with the correct header,
> probably because the web server configuration contains an
> "AddDefaultCharset" directive.  Try to override that in the virtual host
> configuration with:
>
> AddDefaultCharset Off
> # Alternatively:
> AddDefaultCharset utf-8
>
> See http://httpd.apache.org/docs/2.0/mod/core.html#adddefaultcharset for
> details.  Many Linux vendors have this directive in their web server
> configuration.
>
The pages was indeed being sent to the user as UTF-8 (as specified above).

> In order to make absolutely sure that you really spit out utf-8, you should
> do this:
>
> Locale::Messages::nl_putenv ("LANGUAGE=nb_NO.utf8");
> Locale::Messages::nl_putenv ("LANG=nb_NO.utf8");
> Locale::Messages::nl_putenv ("LC_ALL=nb_NO.utf8");
> Locale::Messages::nl_putenv ("LC_MESSAGES=nb_NO.utf8");
> Locale::Messages::nl_putenv ("OUTPUT_CHARSET=utf-8");
> setlocale (LC_ALL, "");
>
> This should do the trick.

This did not work at all. But when I saw the reference to Locale::Messages I
took a look at the POD and I noticed the bind_textdomain_codeset function.
So what I was left with was this, and now it magically works!

       Locale::Messages::bind_textdomain_codeset('portfolio','utf-8');
       setlocale(LC_MESSAGES,$lang_default);

BTW: The $lang_default variable contains nb_NO and
nb/LC_MESSAGES/portfolio.po contains ISO-8859-1 strings, so the recoding does
indeed work as it should now.

Thanks a lot for sorting out my little headache!

Regards,
Robin Smidsrød
Attachments
 1  +-index.html message/rfc822  

ATTENTION: HTML attachments to this mail have been converted to plain text to prevent you from possibly malicious HTML files. Other attachments are included here without any checking. Choose your own poison! The maintainers of this site cannot be held responsible for any damage caused by these attachments.

 Weird character set problem
 Previous Thread
 Next Thread
 Start of Thread
 Reference
 Previous Reply
 This Message
 Reply
 Next Reply
 
 09/01/05 08:09:44 GMT  Robin Smidsrød
 09/01/05 11:13:49 GMT  +--Guido Flohr
 09/01/05 13:54:19 GMT    +--Robin Smidsrød

Powered by Imperia
Home | Top | Imprint