diff --git a/src/MbWrapper.php b/src/MbWrapper.php index 3c7cea6..aff9cb5 100644 --- a/src/MbWrapper.php +++ b/src/MbWrapper.php @@ -334,6 +334,7 @@ private function getNormalizedCharset($charset) */ public function convert($str, $fromCharset, $toCharset) { + // there may be some mb-supported encodings not supported by iconv (on my libiconv for instance // HZ isn't supported), and so it may happen that failing an mb_convert_encoding, an iconv // may also fail even though both support an encoding separately. @@ -341,6 +342,11 @@ public function convert($str, $fromCharset, $toCharset) $from = $this->getMbCharset($fromCharset); $to = $this->getMbCharset($toCharset); + + // Skip conversion if charset is the same + if ($from === $to) { + return $str; + } if ($str !== '') { if ($from !== false && $to === false) {