I have a file that has a Unicode name, say 'קובץ.txt'
. I want to pack him, and I'm using python's zipfile.
I can zip the files and open them later on with a problem except that file names are messed up when using windows 7 file explorer to view the files (7zip works great).
According to the docs, this is a common problem, and there are instructions on how to deal with that:
From ZipFile.write
Note
There is no official file name encoding for ZIP files. If you have unicode file names, you must convert them to byte strings in your desired encoding before passing them to write(). WinZip interprets all file names as encoded in CP437, also known as DOS Latin.
Sorry, but I can't seem to get what exactly am I supposed to do with the filename. I've tried .encode('CP437')
, .decode('CP437')
..