Skip to content

Feature: Add ZIP encoding selection support for browsing archives with non-UTF-8 filenames#18529

Open
oxygen-dioxide wants to merge 10 commits into
files-community:mainfrom
oxygen-dioxide:zip-encoding-oc
Open

Feature: Add ZIP encoding selection support for browsing archives with non-UTF-8 filenames#18529
oxygen-dioxide wants to merge 10 commits into
files-community:mainfrom
oxygen-dioxide:zip-encoding-oc

Conversation

@oxygen-dioxide
Copy link
Copy Markdown
Contributor

Problem
When opening a ZIP archive whose filenames use an encoding other than the user's OS encoding, the filenames appear garbled

Solution
Added a ComboBox in the navigation toolbar that appears when browsing a ZIP archive with undetermined encoding, allowing the user to select the appropriate character encoding. When a custom encoding is selected, the app switches from SevenZipSharp to SharpZipLib to read filenames and file contents.

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.

  1. Download this zip file: japanese-example.zip
  2. In Files, double click this file to open it
  3. Select "Japanese (Shift-JIS)" encoding

previous behaviour:
image

current behaviour:
image

@oxygen-dioxide
Copy link
Copy Markdown
Contributor Author

oxygen-dioxide commented May 30, 2026

Problem: users still can't double-click a file in the archive to open it because process.Start() doesn't support custom zip encoding. (However, this bug also occurs for 7z files, so I may create another PR to fix it.)

Comment thread src/Files.App/UserControls/NavigationToolbar.xaml Outdated
@oxygen-dioxide
Copy link
Copy Markdown
Contributor Author

moved the combobox to bottom right corner
image

@yair100
Copy link
Copy Markdown
Member

yair100 commented Jun 1, 2026

Thanks! I'd like to take a closer look and get some feedback from @mdtauk but I can already tell that the overall location looks a lot better in that screenshot.

@yair100
Copy link
Copy Markdown
Member

yair100 commented Jun 4, 2026

What do you think about replacing the ComboBox with a Button and Flyout like we do for git branches? Please let me know if you want me to push a commit.
image

@oxygen-dioxide
Copy link
Copy Markdown
Contributor Author

What do you think about replacing the ComboBox with a Button and Flyout like we do for git branches? Please let me know if you want me to push a commit. image

Looks good to me

Comment thread src/Files.App/ViewModels/UserControls/NavigationToolbarViewModel.cs
@yair100
Copy link
Copy Markdown
Member

yair100 commented Jun 4, 2026

What's the expected behavior when opening a regular zip file?

@oxygen-dioxide
Copy link
Copy Markdown
Contributor Author

oxygen-dioxide commented Jun 6, 2026

  • src/Files.App/Data/Items/EncodingItem.cs — Changed the built-in Chinese encoding from gb2312 to gb18030, which is a strict superset and matches the encoding name returned by DetectEncodingAsync.
  • src/Files.App/Services/Storage/StorageArchiveService.cs — In IsEncodingUndeterminedAsync, entries whose names consist entirely of ASCII characters are now considered determined (not undetermined), even if they don't declare Unicode. This avoids showing the encoding picker when the zip content is pure ASCII and doesn't need a specific non-UTF-8 encoding.
  • src/Files.App/Data/Models/DirectoryPropertiesViewModel.cs (the StatusBarViewModel) — When auto-detect finds an encoding not present in the built-in list, it dynamically creates an EncodingItem for it and appends it to the options, ensuring the detected encoding always appears in the dropdown.

@oxygen-dioxide
Copy link
Copy Markdown
Contributor Author

What's the expected behavior when opening a regular zip file?

For ascii or utf-8 zip file, the encoding selector shouldn't show up. I've fixed my code.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug: File names for Japanese zips aren't shown correctly on Chinese language

2 participants