Re:Explainer: .DS_Store Files
by nicbou on Sunday November 28, 2021 @07:30AM
(#29368402)
Another issue with zip files on OSX:
> Zip files can encode their file names in two ways: CP437, or unicode.
> Each operating system does it wrong, but in a different way. For instance, Mac OS encodes its zip files as unicode, but doesn't set bit 11 correctly, so Python (correctly) reads them as CP437, and garbles the non-ASCII characters in file names.
> I wrote a quick and dirty workaround for Mac OS archives: if the file doesn't exist, encode the name as CP437 and check again. I'll think of something more clever if I ever switch to another OS.
> Zip files can encode their file names in two ways: CP437, or unicode.
> Each operating system does it wrong, but in a different way. For instance, Mac OS encodes its zip files as unicode, but doesn't set bit 11 correctly, so Python (correctly) reads them as CP437, and garbles the non-ASCII characters in file names.
> I wrote a quick and dirty workaround for Mac OS archives: if the file doesn't exist, encode the name as CP437 and check again. I'll think of something more clever if I ever switch to another OS.
https://nicolasbouliane.com/projects/timeline