Bug #71034 [Opn->Fbk]: Can't add UTF-8 filenames as UTF-8 to ZIP archive
| From: | ab@php.net | Date: | Sat, 05 Dec 2015 02:07:16 +0000 |
| Subject: | Bug #71034 [Opn->Fbk]: Can't add UTF-8 filenames as UTF-8 to ZIP archive | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-197607@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=71034&edit=1
ID: 71034
Updated by: ab@php.net
Reported by: slavikca at gmail dot com
Summary: Can't add UTF-8 filenames as UTF-8 to ZIP archive
-Status: Open
+Status: Feedback
Type: Bug
Package: Zip Related
Operating System: Ubuntu 14.04
PHP Version: 5.6.16
Block user comment: N
Private report: N
New Comment:
Please check the following:
- is the current locale UTF-8
- is the terminal charset UTF-8
- is the actual filename string used in PHP UTF-8, especially the filename is hardcoded - your
script is UTF-8 encoded file
Only if all of these match, it could be a bug in PHP on in libzip.
Thanks.
Previous Comments:
------------------------------------------------------------------------
[2015-12-04 21:45:39] slavikca at gmail dot com
In case, if it was not clear from my original issue description:
output of "unzip" from linux shows UTF-8 characters. So, that is example of adding
filename correctly, in UTF-8.
output of "unzip" from file, create in PHP shows filename seemingly correctly (same as
original), but it is not in UTF-8.
That's bad, because it will show correct filename only in the systems with same locale
settings. If it is different - it will be garbled. But UTF-8 will work correctly 100% on any system
(which supports UTF-8) with any locale.
------------------------------------------------------------------------
[2015-12-04 21:36:15] slavikca at gmail dot com
Description:
------------
*Steps to reproduce*
- use ZipArchive to archive file, which has UTF-8 characters in it.
Test script:
---------------
<?php
$zip = new ZipArchive();
if ($zip->open("test.zip", ZIPARCHIVE::CREATE) !== true)
die ("Failed to create archive");
if (!$zip->addFile("/var/www/test/web/ÑеÑÑ123")) //here are UTF-8
characters in the filename
print ("Failure adding file");
$zip->close();
Expected result:
----------------
the name of archived file will be stored as UTF-8
Actual result:
--------------
file successfully archived. But it's names stored not in UTF-8.
To see, if filename was stored au UTF-8 or not, you can use "-U" option in unzip utility:
Here is output for archive created in PHP:
# unzip -l -U test.zip
...
/var/www/test/web/ÑеÑÑ123
Here is output for archive created by linux zip utility:
# unzip -l -U test2.zip
...
/var/www/test/web/#U0442#U0435#U0441#U0442123
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=71034&edit=1