I am writing something like auto-compress files and upload to server, and I'm using writestr
to directly write bytes to ZipFile
from memory. But for historical problems, I need to make it display properly on some Windows PC with GBK
encoding.
Python3's str
encoding is default utf-8
. I want to know how to write the correct byte stream for the filename, the content can work with utf-8
so no need to care file content.
I need a code sample. Thanks. Any solution is acceptable like new a class inherit it.
Thanks to @tripleee.
Override
_encodeFilenameFlags
method works: