Feature: Use UTF-8 encoding for ZIP creation to ensure cross-language compatibility #17026
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Currently, when creating ZIP archives,
Filesdefaults to the system local encoding (e.g., GBK for Chinese, Shift_JIS for Japanese). UTF-8 is used only when there are characters in file name that can't be expressed in system encoding. This causes filenames to become unreadable when the archive is opened on systems with a different language locale. For example, a Chinese user creates a ZIP with filenames in GBK → Japanese users extract it as Shift_JIS → garbled text.After this PR,
Filesalways creates ZIP archive in UTF-8 encoding, which is consistent with windows explorer's behaviour. The archive created byFileswill never become garbled no matter who downloads it.Resolved / Related Issues
To prevent extra work, all changes to the Files codebase must link to an approved issue marked as
Ready to build. Please insert the issue number following the hashtag with the issue number that this Pull Request resolves.Steps used to test these changes
Stability is a top priority for Files and all changes are required to go through testing before being merged into the repo. Please include a list of steps that you used to test this PR.
I'm a Chinese developer, so below is how I test it in Simplified Chinese windows. I don't know whether this affects English users and how they'll test this.
pip install zipunicode中文.txtFiles, right click on the file, Compress -> Create 中文.zipzipu 中文.zipPrevious behaviour:
New Behaviour: