Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Jan 26, 2026

ZIP archives created on Windows with Chinese filenames use GBK/GB18030 encoding. Without explicit charset configuration, filenames display as mojibake (e.g., 1-�� - 1����.STL instead of 装配件1 - 盖-2.STL).

Changes

  • Configure ZIP decoder with GB18030 encoding: Added newZipFormat() helper that creates archives.Zip with TextEncoding: simplifiedchinese.GB18030
  • Apply to all ZIP extraction paths: Updated both openArchive() for regular ZIP files and extractZipMultiPart() for split archives
  • Add test coverage: New test creates GBK-encoded ZIP with Chinese filenames and verifies proper extraction

Implementation

func newZipFormat() archives.Zip {
    return archives.Zip{
        TextEncoding: simplifiedchinese.GB18030,
    }
}

// In openArchive()
if _, ok := format.(archives.Zip); ok {
    format = newZipFormat()
}

The mholt/archives library checks the UTF-8 flag in ZIP headers and uses TextEncoding for non-UTF8 filenames. GB18030 is a superset of GBK and handles legacy Chinese-encoded archives.

Original prompt

This section details on the original issue you should resolve

<issue_title>解压文件名乱码</issue_title>
<issue_description>中文乱码
Image</issue_description>

<agent_instructions>Fix it and add test case</agent_instructions>

Comments on the Issue (you are @copilot in this section)

@monkeyWie 自动解压乱码吗?

✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI and others added 3 commits January 26, 2026 01:29
Co-authored-by: monkeyWie <13160176+monkeyWie@users.noreply.github.com>
…password comment

Co-authored-by: monkeyWie <13160176+monkeyWie@users.noreply.github.com>
Co-authored-by: monkeyWie <13160176+monkeyWie@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix filename encoding issue during decompression Fix Chinese filename encoding in ZIP extraction Jan 26, 2026
Copilot AI requested a review from monkeyWie January 26, 2026 01:34
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.

解压文件名乱码

2 participants