0

Im trying to unzip some files using sharpziplib. Problem is, it is returning junk characters instead of special and japanese characters. Is there anyway of converting the filename to unicode before getting the files inside the zip file? I currently have the below code.

 foreach (ZipEntry zipEntry in zf)
                {
                    zipEntry.IsUnicodeText = true;
                    if (!zipEntry.IsFile)
                    {
                        continue;         
                    }
breshi
  • 25
  • 6
  • If you're unzipping files, you should probably only be _checking_ that `IsUnicodeText` property. Changing it will most likely mangle the output if it's not UTF-8. – Nyerguds Apr 05 '18 at 12:10
  • Possible duplicate of [Encoding of files inside a zip (C# / ionic-zip)](https://stackoverflow.com/questions/48441051/encoding-of-files-inside-a-zip-c-ionic-zip) – Nyerguds Apr 05 '18 at 12:16

1 Answers1

0

So i ran out of luck trying to decode these files with sharpziplib. I switched to dotnetzip and changed the encoding to 932 which sharpziplib doesnt seem to have when decompressing? Im gonna answer my own question as I dont see a lot of references regarding this issue and for other people who might encounter this issue in the future.

 using (ZipFile archive = new ZipFile(archiveFilenameIn, Encoding.GetEncoding(932)))
                {
                    archive.Password = password;
                    archive.Encryption = EncryptionAlgorithm.PkzipWeak; 
                    archive.StatusMessageTextWriter = Console.Out;


                    String fullZipToPath = Path.Combine(outFolder, Path.GetFileNameWithoutExtension(archiveFilenameIn));
                    //string directoryName = Path.GetDirectoryName(fullZipToPath);
                    if (fullZipToPath.Length > 0)
                        Directory.CreateDirectory(fullZipToPath);

                    archive.ExtractAll(fullZipToPath, ExtractExistingFileAction.Throw);
                }

EDIT: So i played around with sharpziplib and it actually turned out that i can set the default code page. It was working fine after that.

ZipConstants.DefaultCodePage = 932;
breshi
  • 25
  • 6