From c2561820757946be1fa9209398360f2024c92203 Mon Sep 17 00:00:00 2001 From: Cedric Kastner Date: Wed, 5 Sep 2018 10:19:30 +0200 Subject: [PATCH] fix: https://github.com/tedious/Fetch/issues/208 --- 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..6e0d215 100644 --- a/src/Fetch/MIME.php +++ b/src/Fetch/MIME.php @@ -36,7 +36,9 @@ public static function decode($text, $targetCharset = 'utf-8') foreach (imap_mime_header_decode($text) as $word) { $ch = 'default' === $word->charset ? 'ascii' : $word->charset; - + if ($ch === "ascii" && ($c = strtoupper(mb_detect_encoding($word->text))) !== strtoupper($ch)) { + $ch=$c; + } $result .= iconv($ch, $targetCharset, $word->text); }