You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by Sebastien Pinsonnault <in...@gmail.com> on 2005/09/08 08:41:54 UTC

Problem with french accents using mod perl

Hello,

I hope someone can help me as I cannot find any info on how to solve my 
issue.

I'll try to make this short and sweet.... 

I have a website which has french accents (i.e. é) and I noticed that when a 
page uses mod perl in a cgi, the french accents are all messed up in my 
browser.
But if I take the same script and redirect the output to a html file (ex: 
./login.cgi &> ../test.html), the accents display fine...

The only workaround I have found for now is to hardcode those accents 
directly in the html page (ex: &eacute;).

Does anyone know another way to fix this?

We are running apache undere redhat enterprise linux.

Thanks in advance.

-- 
"Vivre, c'est se reposer dans le présent."
Proverbe indien

Re: Problem with french accents using mod perl

Posted by Clinton Gormley <cl...@traveljury.com>.
On Thu, 2005-09-08 at 02:41 -0400, Sebastien Pinsonnault wrote:

> I have a website which has french accents (i.e. é) and I noticed that
> when a page uses mod perl in a cgi, the french accents are all messed
> up in my browser.
> But if I take the same script and redirect the output to a html file
> (ex: ./login.cgi &> ../test.html), the accents display fine...


Most likely your web pages are setting a different character set to the
one you are using on your computer. So, for instance, your default
character set on your computer may be utf8, but your web pages claim to
be in ISO-8559-1, so the unicode characters that you type in are being
interpreted by the browser incorrectly.

Have a look in the perldocs at :
 - perluniintro
 - perlunicode
 - utf8
 - perlrun (look at command line switch -C)
 - Encode

Also, if you are pulling unicode data out of a MySQL database, you need
to let perl know that the data is unicode, as it doesn't detect it
itself.

________________________________________________________________________

Clinton Gormley clinton@traveljury.com

www.TravelJury.com - For travellers, By travellers




Re: Problem with french accents using mod perl

Posted by Sebastien Pinsonnault <in...@gmail.com>.
Hi guys,

thanks for all your ideas, I will try them out.... it seems the problems is 
intermittent as in once in a while some httpd deamon in apache gets 
corrupted somehow and the problems occurs.

If we stop start the apache, the problem goes away for a little while but it 
comes back....

Boy not easy to pinpoint.... I`ll see with our tech guys here what we could 
do to isolate the corruption issue..

Thanks again for you support.

-Sebastien

On 9/8/05, Clinton Gormley <cl...@traveljury.com> wrote:
> 
> On Thu, 2005-09-08 at 09:40 -0700, David Scott wrote:
> > Um, guys, whatever happened to character entities for non-US ASCII
> > characters (eg &eacute; for e-accent-aigu)? Seems to me it would be
> > easy to write a filter to replace outgoing characters with their
> > character entity equivalents, thereby avoiding character set issues.
> 
> 
> Or use HTML::Entities
> 
> 
> 
> ________________________________________________________________________
> 
> Clinton Gormley clinton@traveljury.com
> 
> www.TravelJury.com <http://www.TravelJury.com> - For travellers, By 
> travellers
> 
> 
> 
> 


-- 
"Vivre, c'est se reposer dans le présent."
Proverbe indien

Re: Problem with french accents using mod perl

Posted by Clinton Gormley <cl...@traveljury.com>.
On Thu, 2005-09-08 at 09:40 -0700, David Scott wrote:
> Um, guys, whatever happened to character entities for non-US ASCII 
> characters (eg &eacute; for e-accent-aigu)?  Seems to me it would be 
> easy to write a filter to replace outgoing characters with their 
> character entity equivalents, thereby avoiding character set issues.


Or use HTML::Entities



________________________________________________________________________

Clinton Gormley clinton@traveljury.com

www.TravelJury.com - For travellers, By travellers




Re: Problem with french accents using mod perl

Posted by John ORourke <jo...@versatilia.com>.
David Scott wrote:

> Um, guys, whatever happened to character entities for non-US ASCII 
> characters (eg &eacute; for e-accent-aigu)?  Seems to me it would be 
> easy to write a filter to replace outgoing characters with their 
> character entity equivalents, thereby avoiding character set issues.
>
> d

Yeah I was thinking about doing that in a system I'm working on, then I 
realised the system might not be sending an HTML document - could be 
text or PDF or anything, so it's better to make sure the headers give 
the character set and that it matches whatever perl is set to (with use 
locale or something).

When I looked into it all properly I realised it'd be easier just to 
make everything use UTF-8, though I'm a bit worried about browser 
support for UTF-8 chars in newer browsers (eg. cellphones).

John



Re: Problem with french accents using mod perl

Posted by Anthony Gardner <cy...@yahoo.co.uk>.
I've had a lot of experience with this.

You have to make sure the data coming into your
program is utf8.

Imagine trying to do a regex on your french chars. It
won't happen. That's why you have to have utf8 enable.

use utf8;

Have a look at perllocale. There's lots of info there.

The intermittent problems, try F5 (refresh) on the
broswer.

Also, if you are using a DB, do some tests. I use
MySQL and by default, it stores data as iso-8859 and
when I converted that data to utf8, the output was
worse. So, I just read the data direct from MySQL.

I've since upgraded to MySQL 4 and haven't had any
probs (touch wood). I haven't looked further into
though.

Also, if data is coming from files, look at using utf8
in the open command.

I hope this helps.

-Ants
--- Jonathan Vanasco <jv...@mastersofbranding.com>
wrote:

> Is there any difference in the document/headers
> themselves from when it 
> works, and when it doesn't?
> 
> 
> 
> On Sep 8, 2005, at 1:16 PM, Sebastien Pinsonnault
> wrote:
> 
> > Hello,
> >
> >  Yep we tried that for the addDefaultCharset but
> the issue still crept 
> > up...
> >
> >  That`s why it pretty much to try and find a
> needle in a haystack.
> >
> >  -Sebastien
> 
> 



		
___________________________________________________________ 
To help you stay safe and secure online, we've developed the all new Yahoo! Security Centre. http://uk.security.yahoo.com

Re: Problem with french accents using mod perl

Posted by Jonathan Vanasco <jv...@mastersofbranding.com>.
Is there any difference in the document/headers themselves from when it 
works, and when it doesn't?



On Sep 8, 2005, at 1:16 PM, Sebastien Pinsonnault wrote:

> Hello,
>
>  Yep we tried that for the addDefaultCharset but the issue still crept 
> up...
>
>  That`s why it pretty much to try and find a needle in a haystack.
>
>  -Sebastien


Re: Problem with french accents using mod perl

Posted by Sebastien Pinsonnault <in...@gmail.com>.
Hello,

Yep we tried that for the addDefaultCharset but the issue still crept up...

That`s why it pretty much to try and find a needle in a haystack.

-Sebastien

On 9/8/05, Jonathan Vanasco <jv...@mastersofbranding.com> wrote:
> 
> Even with the entities, character set issues pop up because browsers ,
> and users, can be stupid.
> 
> i've had character entities show up wrong on browsers because of one
> stupid setting or another. I think the last Safari upgrade to osx
> messed them up.
> 
> I'd suggest doing a
> AddDefaultCharset UTF8
> or whatever charset needed to the appropriate host section of your
> httpd.conf file
> 
> 
> 
> 
> On Sep 8, 2005, at 12:40 PM, David Scott wrote:
> 
> > Um, guys, whatever happened to character entities for non-US ASCII
> > characters (eg &eacute; for e-accent-aigu)? Seems to me it would be
> > easy to write a filter to replace outgoing characters with their
> > character entity equivalents, thereby avoiding character set issues.
> 
> 


-- 
"Vivre, c'est se reposer dans le présent."
Proverbe indien

Re: Problem with french accents using mod perl

Posted by Jonathan Vanasco <jv...@mastersofbranding.com>.
Even with the entities, character set issues pop up because browsers , 
and users, can be stupid.

i've had character entities show up wrong on browsers because of one 
stupid setting or another.   I think the last Safari upgrade to osx 
messed them up.

I'd suggest doing a
	AddDefaultCharset UTF8
or whatever charset needed to the appropriate host section of your 
httpd.conf file




On Sep 8, 2005, at 12:40 PM, David Scott wrote:

> Um, guys, whatever happened to character entities for non-US ASCII 
> characters (eg &eacute; for e-accent-aigu)?  Seems to me it would be 
> easy to write a filter to replace outgoing characters with their 
> character entity equivalents, thereby avoiding character set issues.


Re: Problem with french accents using mod perl

Posted by David Scott <ds...@earthlink.net>.
Um, guys, whatever happened to character entities for non-US ASCII 
characters (eg &eacute; for e-accent-aigu)?  Seems to me it would be 
easy to write a filter to replace outgoing characters with their 
character entity equivalents, thereby avoiding character set issues.

d

Aaron Ross wrote:

>
>> I have a website which has french accents (i.e. é) and I noticed that 
>> when a page uses mod perl in a cgi, the french accents are all messed 
>> up in my browser.
>
>
> Have you verified that the headers and meta data match the character 
> set of the document?
>
> Aaron
>


Re: Problem with french accents using mod perl

Posted by Aaron Ross <aa...@aaronelliotross.com>.
> I have a website which has french accents (i.e. é) and I noticed that when a 
> page uses mod perl in a cgi, the french accents are all messed up in my 
> browser.

Have you verified that the headers and meta data match the character set 
of the document?

Aaron