Skip to content

Support utf-8 for filenames inside the zip #3

@vtexier

Description

@vtexier

My filepathes inside the zip are in UTF-8.

folder31/subtitlehéhà32.stl

But when I download and open the zip, I got this :

  • on Linux :

subtitlehéhà32.stl

  • on Windows

subtitleh+®h+á32.stl

The problem seems to be solved in the zipStream-php project:

rlatkn/ZipStream-PHP@55b9e39

Looking into the code I see that the ZipStreamedResponseBundle
already use the good flag in the general purpose flag

    // tell us that Data Descriptor MUST be send,
    // because crc32&lengths in "local file header" are set to 0
    const ZIP_GENERAL_PURPOSE_DATA_DESCRIPTOR = "\x08\x00";

[edit]
I was mistaken by your custom flag.
I found the solution.
To get correct utf-8 in filepathes, need to set bit 11 in general purpose flags:

    // tell us that Data Descriptor MUST be send,
    // because crc32&lengths in "local file header" are set to 0
    // Encoding must be in UTF-8
    const ZIP_GENERAL_PURPOSE_DATA_DESCRIPTOR = "\x08\x08";

This will force to use UTF-8 in filepathes, so maybe you can set a config parameter to activate this mode.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions