Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

iconv(): Wrong encoding, conversion from "CP936" to "UTF-8" is not allowed #4133

Closed
7 tasks
huelsgp27 opened this issue Aug 8, 2024 · 2 comments
Closed
7 tasks

Comments

@huelsgp27
Copy link

huelsgp27 commented Aug 8, 2024

This is:

- [☑️] a bug report

What is the expected behavior?

load a xls file.

What is the current behavior?

[ERROR] iconv(): Wrong encoding, conversion from "CP936" to "UTF-8" is not allowed[401] in /opt/www/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Shared/StringHelper.php
[ERROR] #0 [internal function]: Hyperf\ExceptionHandler\Listener\ErrorExceptionHandler::Hyperf\ExceptionHandler\Listener{closure}()
#1 /opt/www/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Shared/StringHelper.php(401): iconv()
#2 /opt/www/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Reader/Xls.php(1356): PhpOffice\PhpSpreadsheet\Shared\StringHelper::convertEncoding()
#3 /opt/www/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Reader/Xls.php(587): PhpOffice\PhpSpreadsheet\Reader\Xls->readSummaryInformation()
#4 /opt/www/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Reader/BaseReader.php(194): PhpOffice\PhpSpreadsheet\Reader\Xls->loadSpreadsheetFromFile()

What are the steps to reproduce?

Please provide a Minimal, Complete, and Verifiable example of code that exhibits the issue without relying on an external Excel file or a web server:

<?php

require __DIR__ . '/vendor/autoload.php';

$url = '';
file_put_contents("/tmp/test.xls", file_get_contents($url));
$spreadsheet = IOFactory::load('/tmp/test.xls');

If this is an issue with reading a specific spreadsheet file, then it may be appropriate to provide a sample file that demonstrates the problem; but please keep it as small as possible, and sanitize any confidential information before uploading.

What features do you think are causing the issue

  • [☑️] Reader
  • Writer
  • Styles
  • Data Validations
  • Formula Calculations
  • Charts
  • AutoFilter
  • Form Elements

Does an issue affect all spreadsheet file formats? If not, which formats are affected?

No, only .xls file.

Which versions of PhpSpreadsheet and PHP are affected?

2.2.1

@oleibman
Copy link
Collaborator

oleibman commented Aug 8, 2024

Unable to duplicate. Using your sample code, I succeed and, after loading, I can save to a new (and it appears correct) spreadsheet on my system. Is it possible that iconv does not support CP936 (or, less likely, UTF8) on your system?

@huelsgp27
Copy link
Author

Unable to duplicate. Using your sample code, I succeed and, after loading, I can save to a new (and it appears correct) spreadsheet on my system. Is it possible that iconv does not support CP936 (or, less likely, UTF8) on your system?

Thank you for your reply. After upgrading the libiconv version, it is working now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants