SharpZipLib icon indicating copy to clipboard operation
SharpZipLib copied to clipboard

Comments on entries does not support unicode

Open MagnusBeijer opened this issue 1 year ago • 0 comments

Describe the bug

Setting a comment on an entry with special characters is not respected when reading back the archive. Maybe this is the issue: https://github.com/icsharpcode/SharpZipLib/blob/ff2d7c30bdb2474d507f001bc555405e9f02a0bb/src/ICSharpCode.SharpZipLib/Zip/ZipFile.cs#L2437

Reproduction Code

No response

Steps to reproduce

[Test]
[Category("Zip")]
[Category("CreatesTempFile")]
public void CommentsOnEntriesSupportUnicode()
{
	string tempFile = GetTempFilePath();
	Assert.IsNotNull(tempFile, "No permission to execute this test?");

	tempFile = Path.Combine(tempFile, "SharpZipTest.Zip");
	if (File.Exists(tempFile))
	{
		File.Delete(tempFile);
	}

	using (ZipFile testFile = ZipFile.Create(tempFile))
	{
		testFile.BeginUpdate();
		testFile.Add(new StringMemoryDataSource("Aha"), new ZipEntry("Aha") 
		{
			Comment = "åäö",
			IsUnicodeText = true
		});
		testFile.CommitUpdate();

		Assert.That(testFile, Does.PassTestArchive());
	}

	using (ZipFile testFile = new ZipFile(tempFile))
	{
		Assert.AreEqual("åäö", testFile.First().Comment);
	}
}

Expected behavior

comments should be åäö but is ???

Operating System

No response

Framework Version

No response

Tags

No response

Additional context

No response

MagnusBeijer avatar Sep 09 '24 09:09 MagnusBeijer