Revision d9ab23fa
Von Bernd Bleßmann vor mehr als 8 Jahren hinzugefügt
SL/ReportGenerator.pm | ||
---|---|---|
47 | 47 |
'escape_char' => '"', |
48 | 48 |
'eol_style' => 'Unix', |
49 | 49 |
'headers' => 1, |
50 |
'encoding' => 'UTF-8', |
|
50 | 51 |
}, |
51 | 52 |
}; |
52 | 53 |
$self->{export} = { |
... | ... | |
703 | 704 |
} |
704 | 705 |
|
705 | 706 |
sub _handle_quoting_and_encoding { |
706 |
my ($self, $text, $do_unquote) = @_; |
|
707 |
my ($self, $text, $do_unquote, $encoding) = @_;
|
|
707 | 708 |
|
708 | 709 |
$text = $main::locale->unquote_special_chars('HTML', $text) if $do_unquote; |
709 |
$text = Encode::encode('UTF-8', $text); |
|
710 |
$text = Encode::encode($encoding || 'UTF-8', $text);
|
|
710 | 711 |
|
711 | 712 |
return $text; |
712 | 713 |
} |
... | ... | |
745 | 746 |
|
746 | 747 |
if ($opts->{headers}) { |
747 | 748 |
if (!$self->{custom_headers}) { |
748 |
$csv->print($stdout, [ map { $self->_handle_quoting_and_encoding($self->{columns}->{$_}->{text}, 1) } @visible_columns ]); |
|
749 |
$csv->print($stdout, [ map { $self->_handle_quoting_and_encoding($self->{columns}->{$_}->{text}, 1, $opts->{encoding}) } @visible_columns ]);
|
|
749 | 750 |
|
750 | 751 |
} else { |
751 | 752 |
foreach my $row (@{ $self->{custom_headers} }) { |
... | ... | |
753 | 754 |
|
754 | 755 |
foreach my $col (@{ $row }) { |
755 | 756 |
my $num_output = ($col->{colspan} && ($col->{colspan} > 1)) ? $col->{colspan} : 1; |
756 |
push @{ $fields }, ($self->_handle_quoting_and_encoding($col->{text}, 1)) x $num_output; |
|
757 |
push @{ $fields }, ($self->_handle_quoting_and_encoding($col->{text}, 1, $opts->{encoding})) x $num_output;
|
|
757 | 758 |
} |
758 | 759 |
|
759 | 760 |
$csv->print($stdout, $fields); |
... | ... | |
775 | 776 |
my $num_output = ($row->{$col}{colspan} && ($row->{$col}->{colspan} > 1)) ? $row->{$col}->{colspan} : 1; |
776 | 777 |
$skip_next = $num_output - 1; |
777 | 778 |
|
778 |
push @data, join($eol, map { s/\r?\n/$eol/g; $self->_handle_quoting_and_encoding($_, 0) } @{ $row->{$col}->{data} }); |
|
779 |
push @data, join($eol, map { s/\r?\n/$eol/g; $self->_handle_quoting_and_encoding($_, 0, $opts->{encoding}) } @{ $row->{$col}->{data} });
|
|
779 | 780 |
push @data, ('') x $skip_next if ($skip_next); |
780 | 781 |
} |
781 | 782 |
|
... | ... | |
1026 | 1027 |
|
1027 | 1028 |
Include headers? Default is yes. |
1028 | 1029 |
|
1030 |
=item encoding |
|
1031 |
|
|
1032 |
Character encoding. Default is UTF-8. |
|
1033 |
|
|
1029 | 1034 |
=back |
1030 | 1035 |
|
1031 | 1036 |
=head1 SEE ALO |
Auch abrufbar als: Unified diff
ReportGenerator: CSV-Export: Encoding als Option angeben können.
Default bleibt UTF-8.