From 67581a0dd52e9ad27ca92ce23753b19fc82ac7cb Mon Sep 17 00:00:00 2001 From: Ivan Bragin Date: Fri, 14 Apr 2017 18:54:37 +0700 Subject: [PATCH] Fallback from iconv to mbstring for encoding convertion In some exotic environnement (IBM AIX) it may happens that `//TRANSLIT` is not supported. In that case iconv would return false. We can easily identify the case and fallback on mbstring instead. That should give correct result. Closes #135 Closes #136 --- src/PhpSpreadsheet/Shared/StringHelper.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/PhpSpreadsheet/Shared/StringHelper.php b/src/PhpSpreadsheet/Shared/StringHelper.php index c4945540..2273333d 100644 --- a/src/PhpSpreadsheet/Shared/StringHelper.php +++ b/src/PhpSpreadsheet/Shared/StringHelper.php @@ -468,7 +468,10 @@ class StringHelper public static function convertEncoding($value, $to, $from) { if (self::getIsIconvEnabled()) { - return iconv($from, $to . '//IGNORE//TRANSLIT', $value); + $result = iconv($from, $to . '//IGNORE//TRANSLIT', $value); + if (false !== $result) { + return $result; + } } return mb_convert_encoding($value, $to, $from);