Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature: Added support for changing encoding when extracting ZIP files #17022

Merged
merged 13 commits into from
Apr 9, 2025

Conversation

oxygen-dioxide
Copy link
Contributor

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

ZIP file specifications historically use the system's local encoding (e.g., CP936 for Chinese, Shift_JIS for Japanese) to store filenames, rather than UTF-8. This causes cross-language compatibility issues: for example, filenames created by Japanese users (Shift_JIS) will appear as garbled text when extracted by Chinese users (using GBK/CP936), and vice versa. English-speaking users rarely encounter this issue since most legacy encodings are Latin-compatible, but it remains critical for multilingual users.

This PR adds an encoding selection option during ZIP extraction. Users can manually override the default system encoding (e.g., to Shift_JIS, UTF-8, GBK, Big5, etc.) to ensure filenames are decoded correctly. (defaults to system encoding to reserve backward compatibility)

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 user, so I don't know whether and how the encoding issue affects English users. Below is how I test this on Simplified Chinese windows.

  1. Download this zip file:
    japanese-example.zip
  2. In Files, right click this file, Extract -> Extract Files
  3. Select "Japanese (Shift-JIS)" encoding
    image

The file names in this zip file are Japanese encoded in Shift-JIS. Here are the results of extraction:
Extracted with Shift-JIS (correct)
image

Extracted with default encoding (previous behaviour which is incorrect):
image

TODO

  • Autometically guess encoding
  • Being able to select encoding when viewing a zip file

@yaira2 yaira2 changed the title Feature: Add support for selecting encoding when extracting ZIP files Feature: Added support for selecting encoding when extracting ZIP files Apr 8, 2025
@yaira2 yaira2 added changes requested Changes are needed for this pull request and removed needs - code review labels Apr 8, 2025
yaira2
yaira2 previously approved these changes Apr 8, 2025
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 changes requested Changes are needed for this pull request labels Apr 8, 2025
@yaira2 yaira2 merged commit 28254a9 into files-community:main Apr 9, 2025
6 checks passed
@yaira2 yaira2 changed the title Feature: Added support for selecting encoding when extracting ZIP files Feature: Added support for changing encoding when extracting ZIP files Apr 9, 2025
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.

2 participants