--- /dev/null
+package SL::Iconv;
+
+use Text::Iconv;
+
+use SL::Common;
+
+use vars qw(%converters);
+
+sub get_converter {
+ my ($from_charset, $to_charset) = @_;
+
+ my $index = "${from_charset}::${to_charset}";
+ if (!$converters{$index}) {
+ $converters{$index} = Text::Iconv->new($from_charset, $to_charset) || die;
+ }
+
+ return $converters{$index};
+}
+
+sub convert {
+ my ($from_charset, $to_charset, $text) = @_;
+
+ $from_charset ||= Common::DEFAULT_CHARSET;
+ $to_charset ||= Common::DEFAULT_CHARSET;
+
+ my $converter = get_converter($from_charset, $to_charset);
+ return $converter->convert($text);
+}
+
+1;
+
use IO::File;
use Fcntl qw(:seek);
-use Text::Iconv;
use SL::DBUpgrade2;
use SL::DBUtils;
+use SL::Iconv;
sub new {
$main::lxdebug->enter_sub();
$db_charset ||= Common::DEFAULT_CHARSET;
- my $iconv = Text::Iconv->new($file_charset, $db_charset);
+ my $iconv = SL::Iconv::get_converter($file_charset, $db_charset);
$dbh->begin_work();
$db_charset ||= Common::DEFAULT_CHARSET;
- my $iconv = Text::Iconv->new($file_charset, $db_charset);
-
$dbh->begin_work();
while (<$fh>) {
- $_ = $iconv->convert($_);
+ $_ = SL::Iconv::convert($file_charset, $db_charset, $_);
# Remove DOS and Unix style line endings.
chomp;
my $db_charset = $main::dbcharset;
$db_charset ||= Common::DEFAULT_CHARSET;
- my %converters;
-
foreach my $db (split / /, $form->{dbupdate}) {
next unless $form->{$db};
foreach my $control (@upgradescripts) {
next if ($control->{"applied"});
- if (!$converters{$control->{charset}}) {
- $converters{$control->{charset}} = Text::Iconv->new($control->{charset}, $db_charset);
- }
- $control->{description} = $converters{$control->{charset}}->convert($control->{description});
+ $control->{description} = SL::Iconv::convert($control->{charset}, $db_charset, $control->{description});
$control->{"file"} =~ /\.(sql|pl)$/;
my $file_type = $1;
use SL::Form;
use SL::User;
use SL::USTVA;
+use SL::Iconv;
use CGI::Ajax;
use CGI;
30 => "Ausserordentlicher Aufwand",
31 => "Betriebliche Steuern");
foreach $item (sort({ $a <=> $b } keys(%eur))) {
+ my $text = H(SL::Iconv::convert("ISO-8859-15", $dbcharset, $eur{$item}));
if ($item == $form->{pos_eur}) {
- $select_eur .= qq|<option value=$item selected>|. sprintf("%.2d", $item) .qq|. $eur{$item}</option>\n|;
+ $select_eur .= qq|<option value=$item selected>|. sprintf("%.2d", $item) .qq|. $text</option>\n|;
} else {
- $select_eur .= qq|<option value=$item>|. sprintf("%.2d", $item) .qq|. $eur{$item}</option>\n|;
+ $select_eur .= qq|<option value=$item>|. sprintf("%.2d", $item) .qq|. $text</option>\n|;
}
}
34 => 'Verr.kalk.Kosten',
35 => 'Steuern Eink.u.Ertr.');
foreach $item (sort({ $a <=> $b } keys %bwapos)) {
+ my $text = H(SL::Iconv::convert("ISO-8859-15", $dbcharset, $bwapos{$item}));
if ($item == $form->{pos_bwa}) {
- $select_bwa .= qq|<option value="$item" selected>|. sprintf("%.2d", $item) .qq|. $bwapos{$item}\n|;
+ $select_bwa .= qq|<option value="$item" selected>|. sprintf("%.2d", $item) .qq|. $text\n|;
} else {
- $select_bwa .= qq|<option value="$item">|. sprintf("%.2d", $item) .qq|. $bwapos{$item}\n|;
+ $select_bwa .= qq|<option value="$item">|. sprintf("%.2d", $item) .qq|. $text\n|;
}
}
use SL::PE;
use SL::RP;
use SL::USTVA;
+use SL::Iconv;
1;
" " => "_"
);
+ foreach my $key (keys %replacements) {
+ my $new_key = SL::Iconv::convert("ISO-8859-15", $dbcharset, $key);
+ $replacements{$new_key} = $replacements{$key} if $new_key ne $key;
+ }
+
$form->{statementdate} = $locale->date(\%myconfig, $form->{todate}, 1);
$form->{templates} = "$myconfig{templates}";