Skip to content

Conversation

@oxygen-dioxide
Copy link
Contributor

@oxygen-dioxide oxygen-dioxide commented Apr 7, 2025

Currently, when creating ZIP archives, Files defaults 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, Files always creates ZIP archive in UTF-8 encoding, which is consistent with windows explorer's behaviour. The archive created by Files will 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.

  1. install python, and pip install zipunicode
  2. Create a file with Simplified Chinese filename. for example, 中文.txt
  3. In Files, right click on the file, Compress -> Create 中文.zip
  4. In command line, zipu 中文.zip

Previous behaviour:

* Detected encoding  :  GB2312 | Language:Chinese | Confidence:86%

New Behaviour:

* All file names are properly in UTF8 encoding

@oxygen-dioxide oxygen-dioxide changed the title Use UTF-8 encoding for ZIP creation to ensure cross-language compatibility Feature: Use UTF-8 encoding for ZIP creation to ensure cross-language compatibility Apr 7, 2025
@yaira2 yaira2 added the ready for review Pull requests that are ready for review label Apr 7, 2025
@yaira2 yaira2 requested a review from hishitetsu April 7, 2025 14:23
Copy link
Member

@yaira2 yaira2 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@yaira2 yaira2 added ready to merge Pull requests that are approved and ready to merge and removed ready for review Pull requests that are ready for review labels Apr 8, 2025
@yaira2 yaira2 merged commit bd82384 into files-community:main Apr 8, 2025
6 checks passed
@realwyz
Copy link

realwyz commented Aug 10, 2025

Seems this didn't built in the Files - Preview versions. If the file names contains symbol characters, then Files or Files - Preview creates a zip archive still has problem, while other tools like the Bandizip doesn't.

For example, there's three text files named:

01_1920×1080.txt
02_2560×1600.txt
03_3200×2000.txt

Use Files and Bandizip separately create them into a zip archive, then use unzip -t to test the data, they have different results:

❯ unzip -t test_bandizip.zip
Archive:  test_bandizip.zip
    testing: 01_1920×1080.txt        OK
    testing: 02_2560×1600.txt        OK
    testing: 03_3200×2000.txt        OK
No errors detected in compressed data of test_bandizip.zip.

❯ unzip -t test_files.zip
Archive:  test_files.zip
03_3200×2000.txt:  mismatching "local" filename (03_3200+□2000.txt),
         continuing with "central" filename version
    testing: 03_3200×2000.txt        OK
01_1920×1080.txt:  mismatching "local" filename (01_1920+□1080.txt),
         continuing with "central" filename version
    testing: 01_1920×1080.txt        OK
02_2560×1600.txt:  mismatching "local" filename (02_2560+□1600.txt),
         continuing with "central" filename version
    testing: 02_2560×1600.txt        OK
At least one warning-error was detected in test_files.zip.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready to merge Pull requests that are approved and ready to merge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants