Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What encoding does ZipArchive use to store file names inside the created archive?

I'm using the php ZipArchive class in order to generate a zip archive. I use the second parameter of the addFile method in order to set the name of the file in the archive (since the real file on disk has a different name). Some of the names must contain french accents (such as é). When I download the archive, the accents aren't correctly displayed in the file name. What encoding should I use for the file names ? (the application uses UTF-8)

like image 693
matei Avatar asked Feb 15 '11 14:02

matei


1 Answers

It is php bug #53948, see official bug report.

Suggested workaround (worked for me):

$zip->addFile($file, iconv("UTF-8", "CP852", $local_name));
like image 125
janedbal Avatar answered Nov 14 '22 23:11

janedbal