Make | Bodystyle | Satisfaction | |
1 | ŠKODA | Coupé | 4 |
2 | ŠKODA | Coupé | 5 |
3 | ŠKODA | Coupé | 6 |
4 | Citroën | Coupé | 7 |
5 | Citroën | Coupé | 5 |
6 | Citroën | Coupé | 3 |
Make | Bodystyle | Satisfaction |
�KODA | Coup� | 4 |
�KODA | Coup� | 5 |
�KODA | Coup� | 6 |
Citro�n | Coup� | 7 |
Citro�n | Coup� | 5 |
Citro�n | Coup� | 3 |
A user is having issues when the source data contains Czech characters. As an example (note the Czech Š in SKODA):
#!/usr/bin/perluse strict;use warnings;use Excel::Writer::XLSX;my $workbook = Excel::Writer::XLSX->new( 'data.xlsx' );my $worksheet = $workbook->add_worksheet();my $file = 'data.csv';open FH, '<:encoding(utf8)', $file or die "Couldn't open $file: $!\n";my $row = 0;while ( my $line = <FH> ) {chomp $line;my @items = split /,/, $line;$worksheet->write_row( $row++, 0, \@items );}__END__
utf8 "\x8A" does not map to Unicode at test.pl line XX.
utf8 "\xE9" does not map to Unicode at test.pl line XX.
utf8 "\x8A" does not map to Unicode at test.pl line XX.
utf8 "\xE9" does not map to Unicode at test.pl line XX.
utf8 "\x8A" does not map to Unicode at test.pl line XX.
utf8 "\xE9" does not map to Unicode at test.pl line XX.
utf8 "\xEB" does not map to Unicode at test.pl line XX.
utf8 "\xE9" does not map to Unicode at test.pl line XX.
utf8 "\xEB" does not map to Unicode at test.pl line XX.
utf8 "\xE9" does not map to Unicode at test.pl line XX.
utf8 "\xEB" does not map to Unicode at test.pl line XX.
utf8 "\xE9" does not map to Unicode at test.pl line XX.
where 'XX' is the line that begins with 'while...'.
However, the resultant XLSX file, rather than containing the ? symbols or spaces in place of the Czech characters, contains:
Make | Bodystyle | Satisfaction | |
1 | \x8AKODA | Coup\xE9 | 4 |
2 | \x8AKODA | Coup\xE9 | 5 |
3 | \x8AKODA | Coup\xE9 | 6 |
4 | Citro\xEBn | Coup\xE9 | 7 |
5 | Citro\xEBn | Coup\xE9 | 5 |
6 | Citro\xEBn | Coup\xE9 | 3 |
Make | Bodystyle | Satisfaction | |
1 | Š KODA | Coupé | 4 |
2 | Š KODA | Coupé | 5 |
3 | Š KODA | Coupé | 6 |
4 | Citroën | Coupé | 7 |
5 | Citroën | Coupé | 5 |
6 | Citroën | Coupé | 3 |
Is there are preferred approach for this issue, in terms of explicitly indicating the encoding at file open versus using Encode::decode() when writing the cell contents?