Skip to content

Commit 471eb91

Browse files
committed
mb_convert_encoding(): Illegal character encoding specified #40 fixed
1 parent 15f9055 commit 471eb91

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

src/IMAP/Message.php

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -502,10 +502,14 @@ private function decodeString($string, $encoding) {
502502
* @return mixed|string
503503
*/
504504
private function convertEncoding($str, $from = "ISO-8859-2", $to = "UTF-8") {
505-
if (!$from) {
506-
return mb_convert_encoding($str, $to);
505+
if (function_exists('iconv') && $from!='UTF-7' && $to!='UTF-7') {
506+
return iconv($from, $to, $str);
507+
} else {
508+
if (! $from) {
509+
return mb_convert_encoding($str, $to);
510+
}
511+
return mb_convert_encoding($str, $to, $from);
507512
}
508-
return mb_convert_encoding($str, $to, $from);
509513
}
510514

511515
/**

0 commit comments

Comments
 (0)