Showing 1 changed files with 8 additions and 10 deletions
+8 -10
lib/Gitprep/Git.pm
... ...
@@ -1740,23 +1740,21 @@ sub _dec_guess {
1740 1740
   
1741 1741
   my $enc;
1742 1742
   if (@$encoding_suspects) {
1743
-    for my $encoding_suspect (@$encoding_suspects) {
1744
-      my $ret = Encode::Guess->guess($str, $encoding_suspect);
1745
-      if (ref $ret) {
1746
-        $enc = $encoding_suspect;
1747
-        last;
1748
-      }
1743
+    my $ret = Encode::Guess->guess($str, @$encoding_suspects);
1744
+    if (ref $ret) {
1745
+      $enc = $ret->name;
1746
+    }
1747
+    else {
1748
+      $enc = $self->default_encoding
1749 1749
     }
1750
-    $enc //= $self->default_encoding;
1751 1750
   }
1752 1751
   else {
1753 1752
     $enc = $self->default_encoding;
1754 1753
   }
1755 1754
   
1756
-  my $new_str;
1757
-  eval { $new_str = decode($enc, $str) };
1755
+  $str = decode($enc, $str);
1758 1756
 
1759
-  return $@ ? $str : $new_str;
1757
+  return $str;
1760 1758
 }
1761 1759
 
1762 1760
 sub _dec {