Skip to content

No way to set StringCodec on ZipInputStream & ZipOutputStream #776

Closed

Description

@zhuxb711

[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

Activity

  1. piksel commented on Sep 20, 2022

    @piksel
    Member

    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.

  2. added
    zip
    on Sep 20, 2022
  3. zhuxb711 commented on Sep 20, 2022

    @zhuxb711
    Author

    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) });
  4. linked a pull request that will close this issuefix(zip): cleanup/fix of StringCodec #778on Sep 22, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugzip

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions