Leser: 23
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#!/usr/bin/perl
use strict;
use warnings;
use Class::CSV;
my $csv = Class::CSV->new(
filename => 'test.csv',
fields => [qw/item qty/],
);
$csv->add_line({
item => "ütem",
qty => '2'
});
$csv->print();
Quoteailed to create CSV line from line: ütem
at /Library/Perl/5.8.8/Class/CSV.pm line 257
Class::CSV::Line::string('Class::CSV::Line=HASH(0x992ffc)') called at /Library/Perl/5.8.8/Class/CSV.pm line 435
Class::CSV::string('Class::CSV=HASH(0x9bccec)') called at /Library/Perl/5.8.8/Class/CSV.pm line 443
Class::CSV::print('Class::CSV=HASH(0x9bccec)') called at ./bin/test/ccsv.pl line 17
use utf8;
1 2 3 4 5
use Encode qw(decode); $csv->add_line({ item => decode( 'UTF-8', 'ütem' ), qty => '2' });
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#!/usr/bin/perl
use strict;
use warnings;
use utf8;
use Encode qw(decode);
use Class::CSV;
my $csv = Class::CSV->new(
filename => 'test.csv',
fields => [qw/item qty/],
);
t1($csv);
t2($csv);
$csv->print();
sub t1 {
my $csv = shift;
$csv->add_line({
item => "ütem",
qty => '2'
});
}
sub t2 {
my $csv = shift;
$csv->add_line({
item => decode('UTF-8', "ütem"),
qty => '2'
});
}
QuoteWide character in print at /Library/Perl/5.8.8/Class/CSV.pm line 443.
ütem,2
�tem,2
Quote¸tem,2
QuoteWide character in print at /Library/Perl/5.8.8/Class/CSV.pm line 443.
�tem,2
QuoteMal davn abgesehen, dass ich noch nicht weiß, warum der "Wide character in print"-Fehler kommt, ist das erste ü korrekt, das zweite jedoch nicht. Nicht korrekt i.d.S. dass da kein ü steht.
$title = decode('UTF-8', $title);