1

I am trying to extract a zip with multiple files. Some files have the "§" character in their names ("abc(§7)abc.txt"). When unpacking,

System.IO.Compression.ZipFile.ExtractToDirectory(string sourceArchiveFileName, string destinationDirectoryName);

however, the '§' character is translated into the 'õ' (Latin Small Letter O with Tilde) character.

I have already tried to change the encoding. But there is only ASCII or UTF-8 (default)

System.IO.Compression.ZipFile.ExtractToDirectory(sourceArchiveFileName, destinationDirectoryName, Encoding entryNameEncoding);

Is someone able to show me the mistake?

Ludendorff
  • 13
  • 3
  • I've been through a bunch of different encodings, and I can't find one where `§` has an encoding which is the same as the UTF-8 encoding of `õ`... In fact, the UTF-8 encoding of `õ` is 2 bytes: are you sure that only the single `§` character is being converted into `õ`, or might it be taking one of the `(` or `)` as well? – canton7 Jan 14 '20 at 14:04
  • I had also searched for correlations, but found none. It is only the single character that is translated. – Ludendorff Jan 14 '20 at 14:26
  • I tried now a diffrent libary: ionic.Zip The result: this time i get "⌡" (Bottom Half Integral) instead "§" – Ludendorff Jan 14 '20 at 14:39

1 Answers1

1

Windows don't behave nicely with unicode file names inside zip. Using the Enconding 850 solves the problem.

Encoding.GetEncoding(850);

It looks like it got fixed in .Net framework 4.8 but I can't test it right now.

Sources:

https://devblogs.microsoft.com/oldnewthing/20180515-00/?p=98755 http://archives.miloush.net/michkap/archive/2012/01/04/10252916.html

André Sanson
  • 440
  • 3
  • 11