From 30e7f78760f8d9968172d6b1ee5099a86e3b8796 Mon Sep 17 00:00:00 2001 From: Moritz Bunkus Date: Wed, 27 Apr 2011 09:48:11 +0200 Subject: [PATCH] Text bei Iconv-Konvertierung nach UTF-8 in Perls internes Encoding umwandeln Und das auch bei Objekt-Aufrufsyntax: $text = SL::Iconv::convert('ISO-8859-15', 'UTF-8', $some_other_text); --- SL/Iconv.pm | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/SL/Iconv.pm b/SL/Iconv.pm index d6ea0cbdf..19b8ca169 100644 --- a/SL/Iconv.pm +++ b/SL/Iconv.pm @@ -37,7 +37,10 @@ sub convert { $to_charset ||= Common::DEFAULT_CHARSET; my $converter = _get_converter($from_charset, $to_charset); - return $converter->convert($text); + $text = $converter->convert($text); + $text = decode("utf-8-strict", $text) if ($to_charset =~ m/^utf-?8$/i) && !Encode::is_utf8($text); + + return $text; } sub _convert { -- 2.20.1