'escape_char' => '"',
'eol_style' => 'Unix',
'headers' => 1,
+ 'encoding' => 'UTF-8',
},
};
$self->{export} = {
}
sub _handle_quoting_and_encoding {
- my ($self, $text, $do_unquote) = @_;
+ my ($self, $text, $do_unquote, $encoding) = @_;
$text = $main::locale->unquote_special_chars('HTML', $text) if $do_unquote;
- $text = Encode::encode('UTF-8', $text);
+ $text = Encode::encode($encoding || 'UTF-8', $text);
return $text;
}
if ($opts->{headers}) {
if (!$self->{custom_headers}) {
- $csv->print($stdout, [ map { $self->_handle_quoting_and_encoding($self->{columns}->{$_}->{text}, 1) } @visible_columns ]);
+ $csv->print($stdout, [ map { $self->_handle_quoting_and_encoding($self->{columns}->{$_}->{text}, 1, $opts->{encoding}) } @visible_columns ]);
} else {
foreach my $row (@{ $self->{custom_headers} }) {
foreach my $col (@{ $row }) {
my $num_output = ($col->{colspan} && ($col->{colspan} > 1)) ? $col->{colspan} : 1;
- push @{ $fields }, ($self->_handle_quoting_and_encoding($col->{text}, 1)) x $num_output;
+ push @{ $fields }, ($self->_handle_quoting_and_encoding($col->{text}, 1, $opts->{encoding})) x $num_output;
}
$csv->print($stdout, $fields);
my $num_output = ($row->{$col}{colspan} && ($row->{$col}->{colspan} > 1)) ? $row->{$col}->{colspan} : 1;
$skip_next = $num_output - 1;
- push @data, join($eol, map { s/\r?\n/$eol/g; $self->_handle_quoting_and_encoding($_, 0) } @{ $row->{$col}->{data} });
+ push @data, join($eol, map { s/\r?\n/$eol/g; $self->_handle_quoting_and_encoding($_, 0, $opts->{encoding}) } @{ $row->{$col}->{data} });
push @data, ('') x $skip_next if ($skip_next);
}
Include headers? Default is yes.
+=item encoding
+
+Character encoding. Default is UTF-8.
+
=back
=head1 SEE ALO