Subject: Re: bug#65305: 29.1; archive-mode can not handle subfile names encoded with utf-8

From: Eli Zaretskii <[email-masked]>
Date: Tue, 15 Aug 2023 14:33:37 +0300

> From: [email-masked]
> Date: Tue, 15 Aug 2023 13:31:16 +0900
> 
> 
> With python 3.10, ZIP archive can be created with:
>   python -m zipfile -c ARCHIVE.zip subfile
> 
> If the subfile name contains non-ASCII characters, they are encoded with
> utf-8 in anyway. Such subfile names are decoded with local language
> encoding(cp932 for Japanese Windows OS) in archive-mode.
> 
> For example, archive 一.txt in test.zip with python:
>   python -m zipfile -c test.zip 一.txt
> The subfile name is shown as 荳\200.txt in archive-mode buffer and the
> entry can not be extracted. 

Is there any way of distinguishing these Python-created ZIP archives
from ZIP archives created by other Windows programs?

Emacs by default assumes that file names in a ZIP archive created by a
Windows program are encoded in the console codepage, and it enforces
using that encoding for file names when the "creator" of the ZIP
archive indicates the archive was created by Windows programs such as
InfoZip's zip.exe and the File Explorer.  In my testing, zip archives
created by Python as above record the "creator" as number 0 (zero),
which is identical to what InfoZip does.  So, unless someone explains
how to distinguish these zip archives from those created by InfoZip, I
don't see how can Emacs know whether to use the InfoZip heuristics or
the Python heuristics.  Without the InfoZip/File Explorer heuristics
we have in arc-mode.el today, Emacs on Windows would be completely
unable to support non-ASCII file names in ZIP archives.