parent
699da09176
commit
3b0c686630
|
@ -26,6 +26,7 @@ and this project adheres to [Semantic Versioning](https://semver.org).
|
|||
- Fix color from CSS when reading from HTML - [#831](https://github.com/PHPOffice/PhpSpreadsheet/pull/831)
|
||||
- Fix infinite loop when reading invalid ODS files - [#832](https://github.com/PHPOffice/PhpSpreadsheet/pull/832)
|
||||
- Fix time format for duration is incorrect - [#666](https://github.com/PHPOffice/PhpSpreadsheet/pull/666)
|
||||
- Fix iconv unsupported `//IGNORE//TRANSLIT` on IBM i - [#791](https://github.com/PHPOffice/PhpSpreadsheet/issues/791)
|
||||
|
||||
## [1.5.2] - 2018-11-25
|
||||
|
||||
|
|
|
@ -44,6 +44,7 @@
|
|||
"ext-dom": "*",
|
||||
"ext-gd": "*",
|
||||
"ext-iconv": "*",
|
||||
"ext-fileinfo": "*",
|
||||
"ext-libxml": "*",
|
||||
"ext-mbstring": "*",
|
||||
"ext-SimpleXML": "*",
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
||||
"This file is @generated automatically"
|
||||
],
|
||||
"content-hash": "5e66d1016f24ad7d6495ed4d7a04234d",
|
||||
"content-hash": "d70247696f417581626dde9641b53bdc",
|
||||
"packages": [
|
||||
{
|
||||
"name": "markbaker/complex",
|
||||
|
@ -3197,6 +3197,7 @@
|
|||
"ext-dom": "*",
|
||||
"ext-gd": "*",
|
||||
"ext-iconv": "*",
|
||||
"ext-fileinfo": "*",
|
||||
"ext-libxml": "*",
|
||||
"ext-mbstring": "*",
|
||||
"ext-simplexml": "*",
|
||||
|
|
|
@ -53,6 +53,13 @@ class StringHelper
|
|||
*/
|
||||
private static $isIconvEnabled;
|
||||
|
||||
/**
|
||||
* iconv options.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private static $iconvOptions = '//IGNORE//TRANSLIT';
|
||||
|
||||
/**
|
||||
* Build control characters array.
|
||||
*/
|
||||
|
@ -243,39 +250,26 @@ class StringHelper
|
|||
return self::$isIconvEnabled;
|
||||
}
|
||||
|
||||
// Assume no problems with iconv
|
||||
self::$isIconvEnabled = true;
|
||||
|
||||
// Fail if iconv doesn't exist
|
||||
if (!function_exists('iconv')) {
|
||||
self::$isIconvEnabled = false;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
// Sometimes iconv is not working, and e.g. iconv('UTF-8', 'UTF-16LE', 'x') just returns false,
|
||||
if (!@iconv('UTF-8', 'UTF-16LE', 'x')) {
|
||||
} elseif (!@iconv('UTF-8', 'UTF-16LE', 'x')) {
|
||||
// Sometimes iconv is not working, and e.g. iconv('UTF-8', 'UTF-16LE', 'x') just returns false,
|
||||
self::$isIconvEnabled = false;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
// Sometimes iconv_substr('A', 0, 1, 'UTF-8') just returns false in PHP 5.2.0
|
||||
// we cannot use iconv in that case either (http://bugs.php.net/bug.php?id=37773)
|
||||
if (!@iconv_substr('A', 0, 1, 'UTF-8')) {
|
||||
} elseif (defined('PHP_OS') && @stristr(PHP_OS, 'AIX') && defined('ICONV_IMPL') && (@strcasecmp(ICONV_IMPL, 'unknown') == 0) && defined('ICONV_VERSION') && (@strcasecmp(ICONV_VERSION, 'unknown') == 0)) {
|
||||
// CUSTOM: IBM AIX iconv() does not work
|
||||
self::$isIconvEnabled = false;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
// CUSTOM: IBM AIX iconv() does not work
|
||||
if (defined('PHP_OS') && @stristr(PHP_OS, 'AIX') && defined('ICONV_IMPL') && (@strcasecmp(ICONV_IMPL, 'unknown') == 0) && defined('ICONV_VERSION') && (@strcasecmp(ICONV_VERSION, 'unknown') == 0)) {
|
||||
self::$isIconvEnabled = false;
|
||||
|
||||
return false;
|
||||
// Deactivate iconv default options if they fail (as seen on IMB i)
|
||||
if (self::$isIconvEnabled && !@iconv('UTF-8', 'UTF-16LE' . self::$iconvOptions, 'x')) {
|
||||
self::$iconvOptions = '';
|
||||
}
|
||||
|
||||
// If we reach here no problems were detected with iconv
|
||||
self::$isIconvEnabled = true;
|
||||
|
||||
return true;
|
||||
return self::$isIconvEnabled;
|
||||
}
|
||||
|
||||
private static function buildCharacterSets()
|
||||
|
@ -453,7 +447,7 @@ class StringHelper
|
|||
public static function convertEncoding($value, $to, $from)
|
||||
{
|
||||
if (self::getIsIconvEnabled()) {
|
||||
$result = iconv($from, $to . '//IGNORE//TRANSLIT', $value);
|
||||
$result = iconv($from, $to . self::$iconvOptions, $value);
|
||||
if (false !== $result) {
|
||||
return $result;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue