From 0fb94d262d57fa6a301bb55991f23a9e8e9ea0d9 Mon Sep 17 00:00:00 2001 From: Jascha Luelsdorf Date: Wed, 28 Oct 2015 12:51:07 +0100 Subject: [PATCH 1/2] Added switch to avoid 'incomplete multibyte character' when converting utf-8 to utf-8 --- src/Fetch/MIME.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/Fetch/MIME.php b/src/Fetch/MIME.php index b63d72b..8725ce7 100644 --- a/src/Fetch/MIME.php +++ b/src/Fetch/MIME.php @@ -37,7 +37,9 @@ public static function decode($text, $targetCharset = 'utf-8') foreach (imap_mime_header_decode($text) as $word) { $ch = 'default' === $word->charset ? 'ascii' : $word->charset; - $result .= iconv($ch, $targetCharset, $word->text); + if (strtoupper($ch) != strtoupper($targetCharset)) { + $result .= iconv($ch, $targetCharset, $word->text); + } } return $result; From d30577672d467faa76a4f48d3c325ea0d0c01d0f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jascha=20L=C3=BClsdorf?= Date: Tue, 3 May 2016 11:16:55 +0200 Subject: [PATCH 2/2] Fixed bug that made subjects be empty --- src/Fetch/MIME.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/Fetch/MIME.php b/src/Fetch/MIME.php index 8725ce7..4f21616 100644 --- a/src/Fetch/MIME.php +++ b/src/Fetch/MIME.php @@ -40,6 +40,9 @@ public static function decode($text, $targetCharset = 'utf-8') if (strtoupper($ch) != strtoupper($targetCharset)) { $result .= iconv($ch, $targetCharset, $word->text); } + else { + $result .= $word->text; + } } return $result;