Skip Menu |
 

This queue is for tickets about the Data-Table-Excel CPAN distribution.

Report information
The Basics
Id: 91190
Status: resolved
Priority: 0/
Queue: Data-Table-Excel

People
Owner: Nobody in particular
Requestors: sergio [...] serjux.com
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: 0.3
Fixed in: 0.3



Subject: doesn't deal with utf8
Download (untitled) / with headers
text/plain 521b
use strict; use warnings; use utf8; use open ':encoding(utf8)'; binmode(STDOUT, ":utf8"); binmode(STDERR, ":utf8"); # have to write my csv encoded in cp1252 ! open(FCSV, ">:encoding(cp1252)", "$file.csv"); print FCSV $csv->string(); # load file into table my $table = Data::Table::fromFile("$file.csv"); Data::Table::Excel::tables2xlsx("$BASExlsx", [$table], ["something"], [["white","silver","gray"]]); I have to change encoding to cp1252 (>:encoding(cp1252)) or nonascii characters appears double encoding .
From: sergio [...] serjux.com
Download (untitled) / with headers
text/plain 453b
Samples , see that utf-8 tab have a bad characters . Seems a problem of Data::Table::fromFile ... btw , I managed to not use Class::CSV , and do Tables directly with something like : my $table = new Data::Table($data, $header, 0); Data::Table::Excel::tables2xlsx("$file", [$table], ["tab name"], [["white","silver","gray"]]); and don't need enconding tricks anymore , works with utf-8 . So I solved my problem. Thks for this great perl module
Subject: sample.pl
Download sample.pl
text/x-perl 880b
#!/usr/bin/perl #=============================================================================== # # FILE: test.pl # # USAGE: ./test.pl # # DESCRIPTION: # # OPTIONS: --- # REQUIREMENTS: --- # BUGS: --- # NOTES: --- # AUTHOR: YOUR NAME (), # ORGANIZATION: # VERSION: 1.0 # CREATED: 21-11-2013 03:39:03 # REVISION: --- #=============================================================================== use strict; use warnings; use utf8; use open ':encoding(utf8)'; binmode(STDOUT, ":utf8"); binmode(STDERR, ":utf8"); use Data::Table; use Data::Table::Excel; my $t1 = Data::Table::fromFile("sample.cp1252.csv"); my $t2 = Data::Table::fromFile("sample.utf8.csv"); my $a = [$t1, $t2]; my $b = ["sample cp1252", "sample utf8"]; Data::Table::Excel::tables2xlsx("results.xlsx", $a , $b , [["white","silver","gray"]]);
Subject: sample.utf8.csv
qualidade,id,name "Muito má",3667,Zunzún
Subject: sample.cp1252.csv
qualidade,id,name "Muito má",3667,Zunzún
Subject: Re: [rt.cpan.org #91190] doesn't deal with utf8
Date: Mon, 16 Dec 2013 17:04:10 -0800
To: bug-Data-Table-Excel [...] rt.cpan.org
From: Yingyao Zhou <yingyao.zhou [...] gmail.com>
It seems in order to open an UTF-8 file, one has to explicitly specify the encoding method. Currently, the way around this is to provide fromCSV method with a file hander. The following lines will read the utf-8 file correctly. We probably will need to provide encoding as an option parameter to the fromFile/fromCSV method in the future. open(my $fh, '< :encoding(utf8)', "sample.utf8.csv"); my $t1=Data::Table::fromCSV($fh, 1); On Mon, Dec 16, 2013 at 4:19 PM, Sérgio Basto via RT < bug-Data-Table-Excel@rt.cpan.org> wrote: Show quoted text
> Queue: Data-Table-Excel > Ticket <URL: https://rt.cpan.org/Ticket/Display.html?id=91190 > > > > Samples , see that utf-8 tab have a bad characters . > Seems a problem of Data::Table::fromFile ... > > btw , I managed to not use Class::CSV , and do Tables directly with > something like : > > my $table = new Data::Table($data, $header, 0); > Data::Table::Excel::tables2xlsx("$file", [$table], ["tab name"], > [["white","silver","gray"]]); > > and don't need enconding tricks anymore , works with utf-8 . > > So I solved my problem. > > Thks for this great perl module >
Workaround provided.
Data::Table 1.69 will support UTF8 by default (fromFile, fromCSV, fromTSV methods updated).


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

Please report any issues with rt.cpan.org to rt-cpan-admin@bestpractical.com.