When I develop one of my cases, there is a requirement to generate a zip file. So I find a package
laravel-zipstream to do it.
Everything is fine until my customer told me files should be placed in a specific path which contains chinese characters. (´;ω;`)
At begining, I just change the filename like:
$zip = Zip::create('user_data.zip');
But when I download this zip, I get something like:
Where is my filename and folder name :(
At begining, I thought it’s some encoding problem. But I tried to change encoding and still got the same result.
So I went to looked up the source code, and found:
public function getZipPath(): string
true, it will try to translate filename to ascii by Laravel’s Helper function
Str::ascii()(more information in official doc.).
So I looked up the package’s
// Default options for files added
Thus, we can just add below line in our
.env to use non-ascii characters in filename!
Because I don’t see any description in
README about this feature, so I also open a PR in GitHub to add some description about it.
If you’re interested in it, you can find it here.