Closed
Description
This is:
- a bug report
- a feature request
- not a usage question (ask them on https://stackoverflow.com/questions/tagged/phpspreadsheet or https://gitter.im/PHPOffice/PhpSpreadsheet)
What is the expected behavior?
For example, if you decide whether the iconv options works.
//\phpoffice\phpspreadsheet\src\PhpSpreadsheet\Shared\StringHelper.php
//----- New property -----//
/**
* Is iconv // IGNORE // TRANSLIT dose work?
*
* @var bool
*/
private static $isIconvOptionsEnabled;
//----- New method -----//
/**
* Get whether iconv options is available.
*
* @return bool
*/
public static function getIsIconvOptionsEnabled()
{
if (isset(self::$isIconvOptionsEnabled)) {
return self::$isIconvOptionsEnabled;
}
if (!self::getIsIconvEnabled()) {
self::$isIconvOptionsEnabled = false;
return false;
}
// Not IBM AIX (IBMi)
if (! defined('PHP_OS') || ! @stristr(PHP_OS, 'AIX') ){
self::$isIconvOptionsEnabled = true;
return true;
}
// CUSTOM: IBM iconv "//IGNORE//TRANSLIT" dose not work
if (!@iconv('UTF-8', 'UTF-16LE//IGNORE//TRANSLIT', 'x')) {
self::$isIconvOptionsEnabled = false;
return false;
}
self::$isIconvOptionsEnabled = true;
return true;
}
//----- Change method -----//
public static function convertEncoding($value, $to, $from)
{
if (self::getIsIconvEnabled()) {
if (self::getIsIconvOptionsEnabled()) {
$result = iconv($from, $to . '//IGNORE//TRANSLIT', $value);
}else{
$result = iconv($from, $to , $value);
}
if (false !== $result) {
return $result;
}
}
return mb_convert_encoding($value, $to, $from);
}
What is the current behavior?
My system (IBM i) dose not work "// IGNORE // TRANSLIT" options on iconv.
Then, it outputs the NOTICE log.
What are the steps to reproduce?
The reason is that the iconv's options is always specified in the following code.
public static function convertEncoding($value, $to, $from)
{
if (self::getIsIconvEnabled()) {
$result = iconv($from, $to . '//IGNORE//TRANSLIT', $value);
if (false !== $result) {
return $result;
}
}
return mb_convert_encoding($value, $to, $from);
}
Enviroments
PHP version: 7.1
PhpSpreadsheet version: 1.4.1
Metadata
Metadata
Assignees
Labels
No labels