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

Comments on entries does not support unicode #878

Open
MagnusBeijer opened this issue Sep 9, 2024 · 0 comments
Open

Comments on entries does not support unicode #878

MagnusBeijer opened this issue Sep 9, 2024 · 0 comments

Comments

@MagnusBeijer
Copy link

MagnusBeijer commented Sep 9, 2024

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:

byte[] rawComment = (entry.Comment != null) ? Encoding.ASCII.GetBytes(entry.Comment) : Empty.Array<byte>();

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

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

No branches or pull requests

1 participant