libintl-perl

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

 Weird character set problem 
Login Login Subscribe Subscribe  Date  09/01/05 08:09:44 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
Okay, I'm trying to get my webapplication, which uses Locale::TextDomain to
display Norwegian characters, and it's turning out to be a real headache.

Now everything works, but all my national characters turn up on the webage as
question marks.

I use CGI.pm and mod_perl 2.0.1 (apache2), and initially in the application I
set $q->charset('UTF-8').

I generate this header:

Content-Type: text/html; charset=UTF-8

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">;
<html xmlns="http://www.w3.org/1999/xhtml"; xml:lang="nb_NO" lang="nb_NO">
<head>
<title>Grieg Multimedia - Startmappe</title>
<!-- Styles added in priority order -->
<link rel="stylesheet" type="text/css" href="/theme/style.css" />
<link rel="stylesheet" type="text/css" href="/theme/crystal/style.css" />
<link rel="shortcut icon" type="image/ico" href="/favicon.ico" />
<script language="javascript" type="text/javascript"
src="js/index.js"></script>
</head>
<body>

I use this code to initialize the locale-environment:

use POSIX qw(strftime :locale_h);
use Locale::TextDomain ('portfolio');
our $lang_default='nb_NO';
setlocale(LC_MESSAGES,$lang_default);

I've also tried with 'nb_NO.utf8', but it doesn't really make a difference.

The header in lib/LocaleData/nb/LC_MESSAGES/portfolio.po (ISO-8859-1 encoded
strings) is like this:

msgid ""
msgstr ""
"Plural-Forms: nplurals=2; plural=n != 1;\n"
"Project-Id-Version: portfolio\n"
"POT-Creation-Date: 2005-08-17 17:13+0200\n"
"PO-Revision-Date: 2005-08-31 16:24+0100\n"
"Last-Translator: Robin Smidsrød <>\n"
"Language-Team: Norwegian Bokmål <>\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=iso-8859-1\n"
"Content-Transfer-Encoding: 8bit\n"
"X-Poedit-Language: Norwegian Bokmal\n"
"X-Poedit-Country: NORWAY\n"
"X-Poedit-SourceCharset: iso-8859-1\n"

I've also added a UTF-8-encoded version (converted with iconv -f ISO-8859-1 t
UTF-8) of the same file in lib/LocaleData/nb_NO.utf8/LC_MESSAGES/portfolio.po:

msgid ""
msgstr ""
"Plural-Forms: nplurals=2; plural=n != 1;\n"
"Project-Id-Version: portfolio\n"
"POT-Creation-Date: 2005-08-17 17:13+0200\n"
"PO-Revision-Date: 2005-08-25 15:21+0100\n"
"Last-Translator: Robin Smidsrød <>\n"
"Language-Team: Norwegian Bokmål <>\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=utf-8\n"
"Content-Transfer-Encoding: 8bit\n"
"X-Poedit-Language: Norwegian Bokmal\n"
"X-Poedit-Country: NORWAY\n"
"X-Poedit-SourceCharset: iso-8859-1\n"

Both of these files have been compiled with 'msgfmt -c -v -o portfolio.mo
portfolio.po' which succeds without errors.

I've tried changing the $q->charset() command to ISO-8859-1, but that doesn't
make difference to the output.

This my apache2 config:

       PerlSwitches -w -Mlib=/home/xxx/lib
       AddHandler perl-script .pl
       PerlOptions +ParseHeaders
       PerlOptions +SetupEnv
       PerlResponseHandler ModPerl::Registry
       PerlSetVar PORTFOLIO_BINDIR "/home/xxx/bin"
       # Automatic reload check of changed modules at each request, useful in
development
       PerlInitHandler Apache2::Reload

If you can pinpoint what I'm doing wrong I'd be a very happy man! I'm quite
certain it is something related to character conversion, and as far as I can
tell, it looks like my translations get converted to base US-ASCII for some
reason, because my æ (native Norwegian character) gets converted to ae in
output. This is just a hunch, though.

Please advice!

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