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
This commit is contained in:
Ivan Bragin 2017-04-14 18:54:37 +07:00 committed by Adrien Crivelli
parent 8fd1825d39
commit 67581a0dd5
1 changed files with 4 additions and 1 deletions

View File

@ -468,7 +468,10 @@ class StringHelper
public static function convertEncoding($value, $to, $from) public static function convertEncoding($value, $to, $from)
{ {
if (self::getIsIconvEnabled()) { 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); return mb_convert_encoding($value, $to, $from);