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

No way to set StringCodec on ZipInputStream & ZipOutputStream #776

Closed
zhuxb711 opened this issue Sep 20, 2022 · 2 comments · Fixed by #778
Closed

No way to set StringCodec on ZipInputStream & ZipOutputStream #776

zhuxb711 opened this issue Sep 20, 2022 · 2 comments · Fixed by #778
Labels
bug zip Related to ZIP file format

Comments

@zhuxb711
Copy link

[Obsolete("Use ZipFile/Zip*Stream StringCodec instead")]
I got this from the latest version. But ZipInputStream & ZipOutputStream do not provide any StingCodec property and the only one which might be useful constructor is internal
image

Expected behavior

Should allow us to set the StringCodec if ZipStrings.CodePage is obsolete

Actual behavior

No way except the obsolete way to set the StringCodec

Version of SharpZipLib

1.4.0

Obtained from (only keep the relevant lines)

  • Package installed using NuGet
@piksel
Copy link
Member

piksel commented Sep 20, 2022

Yes, you are right, not sure how that happened. There should be getters and setters to access the internal _stringCodec, and perhaps the constructor should be public as well.

@piksel piksel added bug zip Related to ZIP file format labels Sep 20, 2022
@zhuxb711
Copy link
Author

zhuxb711 commented Sep 20, 2022

Use reflection to work around this issue in case someone needs it.

StringCodec Codec = new StringCodec
{
        ForceZipLegacyEncoding = true,
        CodePage = EncodingSetting.CodePage
};

using ZipOutputStream OutputStream = (ZipOutputStream)typeof(ZipOutputStream).GetConstructor(BindingFlags.NonPublic | BindingFlags.Instance, Type.DefaultBinder, new Type[] { typeof(Stream), typeof(StringCodec) });

@piksel piksel linked a pull request Sep 22, 2022 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug zip Related to ZIP file format
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants