-
Notifications
You must be signed in to change notification settings - Fork 3.6k
Closed
Description
This is:
- [ X] a bug report
- [ ] a feature request)
What is the expected behavior?
Correctly load a CSV file with UTF-16LE encoding.
What is the current behavior?
When loading this file, iconv() throws the error:
iconv(): Detected an incomplete multibyte character in input string
This happens in the method:
\PhpOffice\PhpSpreadsheet\Shared\StringHelper::convertEncoding()
Changing the line from:
$result = iconv($from, $to . '//IGNORE//TRANSLIT', $value);
To:
$result = iconv(mb_detect_encoding($from, mb_detect_order(), false), $to . '//IGNORE//TRANSLIT', $value);
Fixes the issue, but I'm not sure if there are any side effects by doing this.
What are the steps to reproduce?
<?php
require __DIR__ . '/vendor/autoload.php';
$path = 'test.csv';
// Create new Spreadsheet object
$reader = new \PhpOffice\PhpSpreadsheet\Reader\Csv();
$reader->setInputEncoding('UTF-16LE');
$reader->setDelimiter(' '); // Tab delimiter
$spreadsheet = $reader->load($path));
### Which versions of PhpSpreadsheet and PHP are affected?
PhpSpreadsheet 1.2.1
PHP 7.2Metadata
Metadata
Assignees
Labels
No labels