Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision 97e60d52

Von Moritz Bunkus vor etwa 15 Jahren hinzugefügt

  • ID 97e60d52d622e6eefe383acfe8e872d7d791493f
  • Vorgänger 94466d5c
  • Nachfolger b974593a

Iconv-Problem behoben

Soll der Inhalt von $form mit Iconv von UTF-8 nach ISO-8859-15
konvertiert werden (z.B. weil der GET-Parameter INPUT_ENCODING auf
UTF-8 gesetzt und $dbcharset = 'ISO-8859-15' ist), so gibt
$iconv->convert($form->{key}) immer undef zurück. Ich weiß nicht
warum.

Übergibt man $iconv->convert() hingegen eine Kopie eines solchen
Wertes aus $form, so wird das erwartete Ergebnis erzeugt.

Unterschiede anzeigen:

SL/Form.pm
if (any { ref $param eq $_ } qw(Form HASH)) {
foreach my $key (keys %{ $param }) {
if (!ref $param->{$key}) {
$param->{$key} = $iconv->convert($param->{$key});
# Workaround for a bug: converting $param->{$key} directly
# leads to 'undef'. I don't know why. Converting a copy works,
# though.
$param->{$key} = $iconv->convert("" . $param->{$key});
} else {
_recode_recursively($iconv, $param->{$key});
}
......
} elsif (ref $param eq 'ARRAY') {
foreach my $idx (0 .. scalar(@{ $param }) - 1) {
if (!ref $param->[$idx]) {
$param->[$idx] = $iconv->convert($param->[$idx]);
# Workaround for a bug: converting $param->[$idx] directly
# leads to 'undef'. I don't know why. Converting a copy works,
# though.
$param->[$idx] = $iconv->convert("" . $param->[$idx]);
} else {
_recode_recursively($iconv, $param->[$idx]);
}

Auch abrufbar als: Unified diff