|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #53948 ZIP archive UTF-8 filenames problem
Submitted: 2011-02-07 14:06 UTC Modified: 2015-05-19 09:27 UTC
From: asaf at lingnu dot com Assigned:
Status: Duplicate Package: Zip Related
PHP Version: 5.3.5 OS: linux
Private report: No CVE-ID:
 [2011-02-07 14:06 UTC] asaf at lingnu dot com
when creating zip archive with non-english filenames, 
the filenames are not encoded correctly, upon extraction
you get them like ???_???.txt.
(tested with various unzipping software on windows/linux)

a suggested workaround, e.g:

$zip->addFile($file_data['path'], iconv("UTF-8","CP852",$file_name));

doesn't help

Test script:

   $zip = new ZipArchive();

   if ($zip->open('/tmp/', ZIPARCHIVE::CREATE) === TRUE) {

      $zip->addFile('/tmp/file.txt', 'קובץ.txt');


      echo "done";

   } else {

      echo "failed";



Expected result:
create a zip file which can be extracted reproducing the original file names.

Actual result:
non english file names comes out corrupted, e.g: ???_???.txt


php-5.3.3-ZIP-UTF8.patch (last revision 2012-02-19 15:47 UTC) by asaf at hadasa-oss dot net)

Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2011-02-18 14:02 UTC]
-Status: Open +Status: Duplicate
 [2011-02-18 14:02 UTC]
 [2011-05-30 08:49 UTC] mikhail dot v dot gavrilov at gmail dot com
I also confirm this problem.

Workaround: Helps converting to your DOS encoding.
 [2011-06-10 23:27 UTC] killerloin at yahoo dot com
is this problem solved yet? I really need a solution.
 [2011-09-23 11:14 UTC] robert at softcom dot no
I also have a problem with this, so bump!
 [2011-12-01 13:49 UTC] nadavkav at gmail dot com
I experience the same issue.
While zipping Hebrew filenames on a CentOS 5.6 (GNU/LINUX) system
with php 5.2.x and 5.3.x
And then, trying to open the Zip file on a Windows XP system
In Which i get ?????.txt as filenames.

Please see more info on the Moodle developer TRACKER system:
 [2013-04-24 17:18 UTC] animelp at yahoo dot com dot ar
same issue with PHP 5.2.14
 [2013-04-24 18:43 UTC]
Use latest pecl release to have UTF-8 support.
 [2013-11-11 08:02 UTC] domnulnopcea at gmail dot com
Even if I use the latest pecl release (beta) the bug is still present!!!
 [2013-12-16 00:14 UTC] danhab2000 at yahoo dot com
Any solutions yet?
מה זה?!
 [2013-12-16 13:30 UTC] danhab2000 at yahoo dot com
Found solution.

To repeat in short, the below suggested workaround would work, except its wrong.  It should be CP862 not CP852.  (for hebrew)  See link.
 [2013-12-16 13:58 UTC]
or update to a more recent php version, 5.4+ or use latest zip from pecl.
 [2015-05-19 07:22 UTC] allan dot mascarenhas1987 at gmail dot com
Can we have fix this issue ? 

PHP Version => 5.3.10-1ubuntu3.17
Extension Version => $Id: php_zip.c 321634 2012-01-01 13:15:04Z felipe $
Zip version => 1.9.1
Libzip version => 0.9.0
Web server => niginx

My problem is i can't update PHP to latest version, due code dependency. 

can someone look into this ?
 [2015-05-19 09:27 UTC]
@allan: PHP 5.3 reached end-of-life last August.
 [2015-05-19 11:44 UTC] allan dot mascarenhas1987 at gmail dot com
Is it fixed in higher versions of PHP ?

Also is there any technical work around to fix this issue ?

We are currently using Drupal 6 CMS, we have around 500+ custom modules and we can't afford heavy testing for this change.
 [2015-11-25 12:51 UTC] 1710ef4e at opayq dot com
2016 is coming soon...
PHP Copyright © 2001-2016 The PHP Group
All rights reserved.
Last updated: Fri Dec 09 07:01:41 2016 UTC