STINNER Victor <victor.stin...@haypocalc.com> added the comment: In #10972, I propose to add an option for the filename encoding to UTF-8. But I would like to force UTF-8 to create a ZIP file, it doesn't concern the decompression of a ZIP file.
Proposal of a specification to fix both issues at the same time. "default_encoding" name is confusing because it doesn't specify if it is the encoding of (text?) file content or the encoding the filename. Why not simply "filename_encoding"? The option can be added in multiple places: - argument to ZipFile constructor: this is needed to decompress - argument to ZipFile.write() and ZipInfo, because they are 3 different manners to add files ZipFile.filename_encoding (and ZipInfo.filename_encoding) will be None by default: in this case, use the current algorithm (try cp437 or use UTF-8). Otherwise, use the encoding. If the encoding is UTF-8: set unicode flag. Examples: --- zipfile.ZipFile("non-ascii-cp932.zip", filename_encoding="cp932") f = zipfile.ZipFile("test.zip", "w") f.write(filename, filename_encoding="UTF-8") info = ZipInfo(filename, filename_encoding="UTF-8") f.writestr(info, b'data') --- Don't add filename_encoding argument to ZipFile.writestr(), because it may conflict if a ZipInfo is passed and ZipInfo.filename_encoding and filename_encoding are different. ---------- _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue10614> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com