# 在 Mac 電腦壓縮含有中文檔名的 ZIP 檔案如何正確在 Windows 下解壓縮

我們公司合作的網頁設計師使用的 Mac 電腦不是 **MBP** ([MacBook Pro](http://www.apple.com/tw/macbookpro/)) 就是 **MBA** ([MacBook Air](http://www.apple.com/tw/macbookair/))，有些已經很習慣用 [Dropbox](http://db.tt/Vr2NmTP) 交換檔案，不過還是有些設計師並沒有在用，而會直接透過**壓縮檔**的方式當成附件寄出，在 Mac 電腦裡內建的壓縮格式為十分常見的 [ZIP 檔案格式](http://en.wikipedia.org/wiki/Zip_\(file_format\))，但是有個問題卻一直困擾著我，那就是他們在 Mac 電腦上壓縮過的 ZIP 檔案跟 Windows 常見的壓縮編碼不相容，如果壓縮檔裡的檔案檔名含有任何非英文的字元（例如中文檔名），解壓縮時就會發生嚴重的亂碼問題，直到這幾天我才找到解決方法。

**註**：以下是為了不變更 Mac 用戶的使用習慣下，解決 Windows 使用者能正常解壓縮 ZIP 檔的方法！

**方法一：安裝** [**Zipeg**](http://www.zipeg.com/) **解壓縮軟體**

該軟體用 Java 寫成，由於與 Windows 相容性較差，他一定要經過安裝程序才能使用 (不算綠色軟體)，且操作介面難用無比，唯一的優點就是可以正確解開 Mac 環境下壓縮過含有中文檔名的 ZIP 檔案，所以我不打算詳細介紹他，有興趣研究的人還是可以用看看。

![](https://stwillblogassets.blob.core.windows.net/files/images/external/stwillblogassets.blob.core.windows.net/845fde3f7bdc069b962c-SNAGHTMLc41a64d.png)

備註：該軟體移除的方法是從控制台的**新增移除程式**移除該軟體。

**方法二：下載 [DotNetZip Library](https://github.com/haf/DotNetZip.Semverd) 的指令列工具 ( UnZip.exe )**

我們先到 [https://www.nuget.org/packages/DotNetZip/](https://www.nuget.org/packages/DotNetZip/) 下載 **DotNetZipTuils** 工具，如下圖示：

![](https://stwillblogassets.blob.core.windows.net/files/images/external/stwillblogassets.blob.core.windows.net/e3ced95919b09aeafb1c-image_1498.png)

要先同意授權條款才能下載檔案（此軟體是 [Ms-PL](http://www.microsoft.com/en-us/openness/licenses.aspx) 授權）

![](https://stwillblogassets.blob.core.windows.net/files/images/external/stwillblogassets.blob.core.windows.net/a63ee7c98d1546ceea6e-image_1499.png)

打開壓縮檔後，如果你只是單一目的【想要解壓縮 Mac 環境下壓縮過含有中文檔名的 ZIP 檔案】的話，那麼你可以僅解壓縮如下圖這兩個檔案即可：

![](https://stwillblogassets.blob.core.windows.net/files/images/external/stwillblogassets.blob.core.windows.net/e6836e4e9ab776a03a15-SNAGHTMLc4ba553.png)

接著，透過命令提示字元即可正確解壓縮 Mac 環境下壓縮過含有中文檔名的 ZIP 檔案！

以下是常見的指令用法：

```
UnZip.exe:  extract or list or test the entries in a zip file.            Depends on Ionic's DotNetZip library. This is version 1.9.1.8 of the utility.usage:  unzip [options] <zipfile> [<entryname>...]     unzips all files in the archive.     options:       -                 emit extracted content to stdout.       -o                overwrite existing files if necessary.       -f                flatten directory structure when extracting.       -p <password>     specify password for extraction.       -t                test the file for consistency.       -q                operate quietly (no verbose messages).       -cp <codepage>    extract with the specified numeric codepage.  Only do this if you                         know the codepage, and it is neither IBM437 nor UTF-8. If the                         codepage you specify here is different than the codepage of                         the cmd.exe, then the verbose messages will look odd, but the                         files will be extracted properly.       -d <directory>    unpack to the specified directory. If none provided, it will                         unzip to the current directory.       <entryname>       unzip only the specified filename.  unzip -l <zipfile>     lists the entries in the zip archive.  unzip -i <zipfile>     displays full information about all the entries in the zip archive.  unzip -t <zipfile> [-p <password>] [-cp <codepage>]     tests the zip archive.  unzip -r <zipfile>     repairs the zip archive - rewriting the directory.  unzip -?     displays this message.
```

若要正確解壓縮 Mac 環境下壓縮過含有中文檔名的 ZIP 檔案，可以參考以下示範步驟：

1\. 我們先找一個 sample.zip 壓縮檔，我們用 [7-zip](http://7-zip.org/) 或 Windows 檔案總管開啟你都會發現檔名都亂掉了！

![](https://stwillblogassets.blob.core.windows.net/files/images/external/stwillblogassets.blob.core.windows.net/18411277d071d14803ed-SNAGHTMLc62580f.png)

2\. 此時我們用 UnZip.exe 搭配 **\-cp 65001** 參數指定壓縮檔內的檔名字碼頁(CodePage)，並搭配 **\-l** 參數顯示檔名就好，我們先不解壓縮：

```
Unzip.exe -cp 65001 -l sample.zip
```

這時你會發現檔名都正常了：

![](https://stwillblogassets.blob.core.windows.net/files/images/external/stwillblogassets.blob.core.windows.net/a6401ca44ac6dfe089e6-image_1500.png)

3\. 最後我們在用相同的參數，但將 **\-l** 參數移除，正式將此檔案解壓縮！

```
Unzip.exe -cp 65001 sample.zip
```

歐耶～ 完美的解壓縮成功了！

![](https://stwillblogassets.blob.core.windows.net/files/images/external/stwillblogassets.blob.core.windows.net/d1e71c69433404610659-image_1501.png)

如果你想解壓縮到特定目錄下，可以加上 **\-d** 參數，如下範例：

```
Unzip.exe -cp 65001 -d sample sample.zip
```

備註：在目前最新版的 DotNetZipUtils-v1.9 工具裡雖然有個 **DotNetZip-WinFormsTool.exe** 視窗工具，但該工具只能正確顯示檔名，卻無法正確解壓縮！此問題我已經回報作者，不過等他們推下一版不知等到何時，所以我自己已經修正原始碼並重新編譯放在這裡，有需要的人可以自行下載。

**§ 給 Mac 用戶的建議**

為了不讓 Windows 使用者在開啟從 Mac 壓縮的 ZIP 檔案時出現亂碼，建議可以下載免費的 [Keka](http://www.kekaosx.com/en/) 壓縮工具 (透過 Apple Store 下載要 2.99 美金，但手動從官網下載 dmg 安裝檔免費)，用這套工具壓縮好的 ZIP 或 7z 檔，都能正常在 Windows 平台正常解壓縮，感謝你們的大德！ ^\_^

**相關連結**

-   [Zip (file format) - Wikipedia, the free encyclopedia](http://en.wikipedia.org/wiki/Zip_\(file_format\))
-   [DotNetZip Library @ CodePlex](https://github.com/haf/DotNetZip.Semverd)
-   [KLab/DotNetZip](https://github.com/KLab/DotNetZip): Forked from http://dotnetzip.codeplex.com/ (Compact Framework only) for using in the Unity iOS/Android platform.
-   [Keka - the free Mac OS X file archiver](http://www.kekaosx.com/en/)
