adamhathcock / sharpcompress

SharpCompress is a fully managed C# library to deal with many compression types and formats.
MIT License
2.29k stars 482 forks source link

Chinese Garbled #338

Open JohnnyWoong opened 6 years ago

JohnnyWoong commented 6 years ago

when i use it, the chinese will be garbled

JohnnyWoong commented 6 years ago

uncompress zip, file extension is jpg

adamhathcock commented 6 years ago

Try setting the encoding on the options.

JohnnyWoong commented 6 years ago

useless,the default setting is utf-8

adamhathcock commented 6 years ago

yeah it is...set it to a different code page

JohnnyWoong commented 6 years ago

what do u mean?set to encode.default?

adamhathcock commented 6 years ago

https://github.com/adamhathcock/sharpcompress/issues/149 is similar

there still might need to be code changes to totally fix things

JohnnyWoong commented 6 years ago

ok,i will try that first,thx

JohnnyWoong commented 6 years ago

y i can delete zip file after i uncompress it,but cant delete 7z file after i uncompress it?

adamhathcock commented 6 years ago

make sure everything is disposed. You'll need to show me a code sample of what you're doing if you think you've disposed everything

JohnnyWoong commented 6 years ago
//zip uncompress and delete
using (var archive = ZipArchive.Open(file))
            {
                foreach (var entry in archive.Entries.Where(entry => !entry.IsDirectory))
                {
                    entry.WriteToDirectory(folder, new ExtractionOptions()
                    {
                        ExtractFullPath = true,
                        Overwrite = true
                    });
                }
            }
File.Delete(file);
//7zip uncompress and delete
using (var archive = RarArchive.Open(file))
            {
                foreach (var entry in archive.Entries.Where(entry => !entry.IsDirectory))
                {
                    entry.WriteToDirectory(folder, new ExtractionOptions()
                    {
                        ExtractFullPath = true,
                        Overwrite = true
                    });
                }
            }
File.Delete(file);
adamhathcock commented 6 years ago

I'll take a look later but RarArchive isn't 7Zip

JohnnyWoong commented 6 years ago

sry,my copy wrong,RarArchive should be SevenZipArchive,the 7z file cant delete,i haven't test rar file

adamhathcock commented 6 years ago

well, I need the exact code, not a copy/guess. As far as I can tell, disposal works correctly.

JohnnyWoong commented 6 years ago
using (var archive = SevenZipArchive.Open(file))
            {
                foreach (var entry in archive.Entries.Where(entry => !entry.IsDirectory))
                {
                    entry.WriteToDirectory(folder, new ExtractionOptions()
                    {
                        ExtractFullPath = true,
                        Overwrite = true
                    });
                }
            }
File.Delete(file);

thats is the code,cause i write 7z,zip and rar,so i copy the wrong one..

adamhathcock commented 6 years ago

I literally tested that and it works for me. Next step for debugging would be for you to provide a github repo sample with the bug that I could validate didn't work.

JohnnyWoong commented 6 years ago

I dont knw y,but same code is work 4 me today...sry abt that By the way,7z uncompress is too slow,250MB zip uncompress only need less 1 min,y 275MB 7z uncompress need about 30M..

binary4cat commented 6 years ago

@JohnnyWongC How do you solve this Chinese garbled problem? 😱

JohnnyWoong commented 6 years ago

I literally tested that and it works for me. Next step for debugging would be for you to provide a github repo sample with the bug that I could validate didn't work.

I test it again,some file can unzip correctly,some file still garbled

test file.zip: https://www.jianguoyun.com/p/DavrLy0Q-c3-BRjQroMB the chinese file in mods directory

protected static void ZipUncompress(string file, string folder)
{
    using (var archive = ZipArchive.Open(file))
    {
        foreach (var entry in archive.Entries.Where(entry => !entry.IsDirectory))
        {
            entry.WriteToDirectory(folder, new ExtractionOptions()
            {
                ExtractFullPath = true,
                Overwrite = true
            });
        }
    }
}
YoungLiao commented 2 years ago

not fixed on version 0.32.2 yet.