Skip to content

Encoding can't be set as intended #274

@Muffexx

Description

@Muffexx

Steps to reproduce

Encode ZipFile using 7Zip (including non ASCII characters like "ä", "ü")
Try to unzip using SharpZipLib with CodePage set to "850".

Expected behavior

Characters should be decoded correctly (including non ASCII characters).

Actual behavior

Non ASCII characters aren't decoded correctly.

Version of SharpZipLib

1.0.0

Obtained from (place an x between the brackets for all that apply)

  • Package installed using:
    • NuGet

Comment

when looking at (in ZipStrings)

private static Encoding EncodingFromFlag(int flags)
			=> ((flags & (int)GeneralBitFlags.UnicodeText) != 0)
				? Encoding.UTF8
                                : Encoding.GetEncoding(_SystemDefaultCodePage_)

I'm not sure whether this is as intended - since the Codepage Property could be used instead of SystemDefaultCodePage.

The only way to get the characters decoded correctly is to encrypt via 7Zip with the cu-flag set to on (7-Zip uses UTF-8 for file names that contain non-ASCII symbols)
or setting the SystemDefaultCodePage via reflection to a suitable codepage.

Maybe a setter for SystemDefaultCodePage can be added
or Codepage can be used in the mentioned code part?

Hope I didn't overlook anything.
regards

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions