Angebot/Auftrag: "Als neu speichern": Warnung bei ungültigen Artikeln
[kivitendo-erp.git] / SL / Iconv.pm
index c2f2247..aba271a 100644 (file)
@@ -19,7 +19,7 @@ sub new {
   return $self;
 }
 
-sub get_converter {
+sub _get_converter {
   my ($from_charset, $to_charset) = @_;
 
   my $index             = join $SUBSCRIPT_SEPARATOR, $from_charset, $to_charset;
@@ -33,11 +33,14 @@ sub convert {
 
   my ($from_charset, $to_charset, $text) = @_;
 
-  $from_charset ||= Common::DEFAULT_CHARSET;
-  $to_charset   ||= Common::DEFAULT_CHARSET;
+  $from_charset ||= 'UTF-8';
+  $to_charset   ||= 'UTF-8';
 
-  my $converter = get_converter($from_charset, $to_charset);
-  return $converter->convert($text);
+  my $converter = _get_converter($from_charset, $to_charset);
+  $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 {