hi,bye,test is great,test
what is your name,is,これ 試験 this is a test,test
####
hi,bye,test is great,test
what is your name,is,"これ 試験 this is a test",test
####
use Text::CSV_XS;
use encoding 'utf8';
my @rows;
my $csv = Text::CSV_XS->new ({ quote_space => 0, binary => 1 }) or
die "Cannot use CSV: ".Text::CSV_XS->error_diag ();
open my $fh, "<:encoding(utf8)", "test.csv" or die "test.csv: $!";
while (my $row = $csv->getline ($fh)) {
push @rows, $row;
}
$csv->eof or $csv->error_diag ();
close $fh;
$csv->eol ("\r\n");
open $fh, ">:encoding(utf8)", "new.csv" or die "new.csv: $!";
$csv->print ($fh, $_) for @rows;
close $fh or die "new.csv: $!";