csv, perl and German umlaute

csv, perl and German umlaute

am 14.09.2007 16:04:34 von Abadiya

Hi,

I'm using Mason/Perl. At the moment I'm trying to pull data out of a
csv-file into an html file with the help of Perl. Works fine but I
have problems with the displayal of German umlaute. Sometimes they are
displayed, sometimes I get questionmarks where the umlaute should be.
Changes almost every time I refresh the page.

I've got this line at the beginning of my code to force the page to
use utf8 but it won't work.
<%method .utf8>

Can you help me?

Best Wishes

Re: csv, perl and German umlaute

am 15.09.2007 01:41:10 von Petr Vileta

abadiya wrote:
> Hi,
>
> I'm using Mason/Perl. At the moment I'm trying to pull data out of a
> csv-file into an html file with the help of Perl. Works fine but I
> have problems with the displayal of German umlaute. Sometimes they are
> displayed, sometimes I get questionmarks where the umlaute should be.
> Changes almost every time I refresh the page.
>
> I've got this line at the beginning of my code to force the page to
> use utf8 but it won't work.
> <%method .utf8>
>
> Can you help me?
>
I don't know what charset you use in html code but for accented characters
you can use HTML entity codes. For example:
lowercase u-umlaute -> ü

uppercase U-umlaute -> Ü

lowercase e-umlaute -> ë

uppercase E-umlaute -> Ë
Take a look here
http://tlt.psu.edu/suggestions/international/web/codehtml.ht ml

--

Petr Vileta, Czech republic
(My server rejects all messages from Yahoo and Hotmail. Send me your mail
from another non-spammer site please.)

Re: csv, perl and German umlaute

am 15.09.2007 07:54:00 von Abadiya

> I don't know what charset you use in html code but for accented
> characters you can use HTML entity codes.

But that would mean I have to use entities within the csv-file? If I
do that Perl stops printing after the first umlaut because of the
semicolon in the entity (e.g. ü). :(

Re: csv, perl and German umlaute

am 16.09.2007 03:53:36 von Petr Vileta

abadiya wrote:
>> I don't know what charset you use in html code but for accented
>> characters you can use HTML entity codes.
>
> But that would mean I have to use entities within the csv-file? If I
> do that Perl stops printing after the first umlaut because of the
> semicolon in the entity (e.g. ü). :(

You wrote in previous message:
> At the moment I'm trying to pull data out of a csv-file into an html
> file...

I mean to read csv file as is and recode on the fly to html entities.
For example csv file is this

---sample.csv---
Jürgen;Däniken;
---sample.csv---

and perl for read scv and send to user browser is this

---readcsv.cgi---
use strict;
use HTML::Entities;
print "Content-type: text/html\n\n",
" charset=iso-8859-2\">",
"\n\n";
open CSV,"< sample.csv" or die "Can't open csv file";
while (my $row = )
{
my ($forname,$surname) = split(/;/, $row);
$forname = encode_entities($forname);
$surrname = encode_entities($surname);
print "$forname $surname\n
";
}
close CSV;
print "\n\n";
---readcsv.cgi---


--

Petr Vileta, Czech republic
(My server rejects all messages from Yahoo and Hotmail. Send me your mail
from another non-spammer site please.)

Re: csv, perl and German umlaute

am 17.09.2007 17:12:11 von Josef Moellers

abadiya wrote:
> Hi,
>=20
> I'm using Mason/Perl. At the moment I'm trying to pull data out of a
> csv-file into an html file with the help of Perl. Works fine but I
> have problems with the displayal of German umlaute. Sometimes they are
> displayed, sometimes I get questionmarks where the umlaute should be.
> Changes almost every time I refresh the page.
>=20
> I've got this line at the beginning of my code to force the page to
> use utf8 but it won't work.
> <%method .utf8>
>=20
> Can you help me?

You know that with Text::CSV_XS you have to specify "binary =3D> 1" with =

the new method to pick up those letters (BTDTGT)?
As you have shown us no code, there's little we can tell about what you=20
may do wrong.

--=20
These are my personal views and not those of Fujitsu Siemens Computers!
Josef Möllers (Pinguinpfleger bei FSC)
If failure had no penalty success would not be a prize (T. Pratchett)
Company Details: http://www.fujitsu-siemens.com/imprint.html