French Accents appear incorrectly...

N

nigel

Hi,

I'm creating a French web site. I've used Dreamweaver to develop most
of the site and have simply typed the french with accents. This all
displays fine. I've used DreamWeaver to create a library object for
the menu of the site (to avoid having multiple copies of exactly the
same html). I've now uploaded the library object to my server in order
that a perl program can read the contents of that file and output a
page of html complete with the menu for the site, but here I've run
into a problem: the accented letters are being displayed incorrectly.
For example an 'é' (e with an acute accent) is being displayed as a
capital A with two dots over it folowed by the copyright symbol. This
only happens for the text that is being read from the library object
file, an e with an acute accent typed into the perl program and
printed directly displays correctly. So I think the problem must be
related to how I read and then write the library object file. Here is
my code:

#######################################################################
######################

# Open and read the contents of the headerMenu template...
open(INPUT, "../Library/headerMenuFr.lbi") ||
&printErrorMessage("Error 001 : Can't open the 'headerMenuFr' file in:
$program");

while(<INPUT>) {
push(@records1,$_);
}

close(INPUT)|| &printErrorMessage("Error 012 : Can't close the
'headerMenuFr' file in: $program");

# Now read through the header and print it...

$recnum = @records1;
for ($i=0; $i<$recnum; $i++) {

print $records1[$i];
}

#######################################################################
#####################

If anyone has any bright ideas as to what I'm doing wrong and how to
correct it, I'd like to hear them!

Thanks in advance,

Nigel
 
G

gf

I'm creating a French web site. I've used Dreamweaver to develop most
of the site and have simply typed the french with accents. This all
displays fine. I've used DreamWeaver to create a library object for
the menu of the site (to avoid having multiple copies of exactly the
same html). I've now uploaded the library object to my server in order
that a perl program can read the contents of that file and output a
page of html complete with the menu for the site, but here I've run
into a problem: the accented letters are being displayed incorrectly.
For example an 'é' (e with an acute accent) is being displayed as a
capital A with two dots over it folowed by the copyright symbol. This
only happens for the text that is being read from the library object
file, an e with an acute accent typed into the perl program and
printed directly displays correctly. So I think the problem must be
related to how I read and then write the library object file. Here is
my code:

OK, first, did you EMBED the accented characters, or did you let
Dreamweaver do the RIGHT thing and use HTML entities?

If you embedded the high-bit-set characters, or used the ALT+number
method of entering an accented character... I'm all for having you
flogged, because that creates a real mess. But it's easily fixed. Just
tell Dreamweaver to convert the characters to HTML entities and resave
the file. And, then, never, EVER directly enter accented characters
again.

Now, typing quick 'n dirty on the fly...
#######################################################################
######################

# Open and read the contents of the headerMenu template...
open(INPUT, "../Library/headerMenuFr.lbi") ||
&printErrorMessage("Error 001 : Can't open the 'headerMenuFr' file in:
$program");

# ALWAYS...
use warnings;
use strict;

# ALWAYS use the three parm form of open...
open (my $INPUT, '<','...') or die $!;
while(<INPUT>) {
push(@records1,$_);
}

while (<$INPUT>) {
print ;
}
close(INPUT)|| &printErrorMessage("Error 012 : Can't close the
'headerMenuFr' file in: $program");

close ($INPUT) or die "Can't close: $!\n";
# Now read through the header and print it...

$recnum = @records1;
for ($i=0; $i<$recnum; $i++) {

print $records1[$i];
}

#######################################################################
#####################

If anyone has any bright ideas as to what I'm doing wrong and how to
correct it, I'd like to hear them!

If you ABSOLUTELY must embed the characters instead of use HTML
entities, then you'll deserve having to learn about UNICODE and
opening the IO layers, but be prepared because you'll be opening
Pandora's box.

perldoc -f open
 
G

Guest

Hi,

I'm creating a French web site. I've used Dreamweaver to develop most
of the site and have simply typed the french with accents. This all
displays fine. I've used DreamWeaver to create a library object for
the menu of the site (to avoid having multiple copies of exactly the
same html). I've now uploaded the library object to my server in order
that a perl program can read the contents of that file and output a
page of html complete with the menu for the site, but here I've run
into a problem: the accented letters are being displayed incorrectly.
For example an 'é' (e with an acute accent) is being displayed as a
capital A with two dots over it folowed by the copyright symbol.

It sounds like the library file was encoded in UTF8, and your perl
program is reading it in iso-8859-1 (or something like that).
This
only happens for the text that is being read from the library object
file, an e with an acute accent typed into the perl program and
printed directly displays correctly. So I think the problem must be
related to how I read and then write the library object file. Here is
my code:

#######################################################################
######################

# Open and read the contents of the headerMenu template...
open(INPUT, "../Library/headerMenuFr.lbi") ||

Try this:

open(INPUT, '<:utf8', "../Library/headerMenuFr.lbi") ||
&printErrorMessage("Error 001 : Can't open the 'headerMenuFr' file in:
$program");

while(<INPUT>) {
push(@records1,$_);
}

close(INPUT)|| &printErrorMessage("Error 012 : Can't close the
'headerMenuFr' file in: $program");

# Now read through the header and print it...

$recnum = @records1;
for ($i=0; $i<$recnum; $i++) {

print $records1[$i];
}

#######################################################################
#####################

If anyone has any bright ideas as to what I'm doing wrong and how to
correct it, I'd like to hear them!

Thanks in advance,

Nigel

Also read "perldoc -f binmode"

HTH
 
M

Marc Espie

OK, first, did you EMBED the accented characters, or did you let
Dreamweaver do the RIGHT thing and use HTML entities?
If you embedded the high-bit-set characters, or used the ALT+number
method of entering an accented character... I'm all for having you
flogged, because that creates a real mess. But it's easily fixed. Just
tell Dreamweaver to convert the characters to HTML entities and resave
the file. And, then, never, EVER directly enter accented characters
again.

Nonsense, unicode in web pages is just fine, has been for ages. If anything,
you just want to declare the right encoding in your headers.
 
N

nigel

Hello again,

Thank you all for your input.

One solution to my problem was certainly to replace the embedded
characters with their html entities, but I thought that gf's comments
were perhaps a bit extreme - I'm working with French web site
developers and they simply type merrily away on their french keyboards
and therefore have embedded characters everywhere without too many
problems apparently.

In the end I opted for Marc Espie's solution which works just fine.

Thanks again,

Nigel







I'm creating a French web site. I've used Dreamweaver to develop most
of the site and have simply typed the french with accents. This all
displays fine. I've used DreamWeaver to create a library object for
the menu of the site (to avoid having multiple copies of exactly the
same html). I've now uploaded the library object to my server in order
that a perl program can read the contents of that file and output a
page of html complete with the menu for the site, but here I've run
into a problem: the accented letters are being displayed incorrectly.
For example an 'é' (e with an acute accent) is being displayed as a
capital A with two dots over it folowed by the copyright symbol.

It sounds like the library file was encoded in UTF8, and your perl
program is reading it in iso-8859-1 (or something like that).
This
only happens for the text that is being read from the library object
file, an e with an acute accent typed into the perl program and
printed directly displays correctly. So I think the problem must be
related to how I read and then write the library object file. Here is
my code:

# Open and read the contents of the headerMenu template...
open(INPUT, "../Library/headerMenuFr.lbi") ||

Try this:

open(INPUT, '<:utf8', "../Library/headerMenuFr.lbi") ||




&printErrorMessage("Error 001 : Can't open the 'headerMenuFr' file in:
$program");
while(<INPUT>) {
push(@records1,$_);
}
close(INPUT)|| &printErrorMessage("Error 012 : Can't close the
'headerMenuFr' file in: $program");
# Now read through the header and print it...
$recnum = @records1;
for ($i=0; $i<$recnum; $i++) {
print $records1[$i];
}
#######################################################################
#####################

If anyone has any bright ideas as to what I'm doing wrong and how to
correct it, I'd like to hear them!
Thanks in advance,

Also read "perldoc -f binmode"

HTH
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,002
Messages
2,570,261
Members
46,858
Latest member
FlorrieTuf

Latest Threads

Top