Skip to content

Commit

Permalink
add example for custom file encoding
Browse files Browse the repository at this point in the history
  • Loading branch information
itn3000 committed May 23, 2018
1 parent 3a747ba commit 7b7af61
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions USAGE.md
Original file line number Diff line number Diff line change
Expand Up @@ -127,3 +127,20 @@ using (var writer = WriterFactory.Open(stream, ArchiveType.Tar, new WriterOption
writer.WriteAll("D:\\temp", "*", SearchOption.AllDirectories);
}
```

### Extract zip which has non-utf8 encoded filename(cp932)

```C#
var opts = new SharpCompress.Readers.ReaderOptions();
var encoding = Encoding.GetEncoding(932);
opts.ArchiveEncoding = new SharpCompress.Common.ArchiveEncoding();
opts.ArchiveEncoding.CustomDecoder = (data, x, y) =>
{
return encoding.GetString(data);
};
var tr = SharpCompress.Archives.Zip.ZipArchive.Open("test.zip", opts);
foreach(var entry in tr.Entries)
{
Console.WriteLine($"{entry.Key}");
}
```

0 comments on commit 7b7af61

Please sign in to comment.