Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

consider switching out zlib for SharpZipLib #87

Open
patrickhuber opened this issue Aug 30, 2019 · 0 comments
Open

consider switching out zlib for SharpZipLib #87

patrickhuber opened this issue Aug 30, 2019 · 0 comments

Comments

@patrickhuber
Copy link

patrickhuber commented Aug 30, 2019

The dependency on zlib uses a c library which lacks a managed interface and regular updates that can be achieved with a nuget package of SharpZipLib.

I implemented a proof of concept decoding the hex codes of www.cityofheroesplanner.com in my data export library here:

Code under test here:

Its pretty simple to get it setup:

install SharpZipLib

install-package SharpZipLib

Create a stream around an existing byte stream (like the hex stream from the encoded build urls)

var encoded = Encoding.ASCII.GetBytes(data.EncodedString);
var decodedBytes = HexUtil.Decode(encoded);
var compressedStream = new MemoryStream(decodedBytes);
_internalStream = new InflaterInputStream(compressedStream);

Read from the internal stream like you would any other stream. For example, wrapping it in a BinaryReader. I happened to encapsulate it in a wrapper class so I could avoid the boiler plate code for setting it up.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant