我正在阅读使用Ionic.Zip.ZipFile类的ZIP文件的注释,并且似乎出现了重音字符的问题(比如“eéêèe”)。在我的例子中,我得到的不是“╔”,而是“╔”。
我的代码是:
using (ZipFile zipFile = new ZipFile(path))
{
comment = zipFile.Comment;
}
路径是ZIP文件的路径。我还试图直接将编码放在一起,但结果是相同的(如下所示):
using (ZipFile zipFile = new ZipFile(path, Encoding.UTF8))
{
comment = zipFile.Comment;
}
注释是否有特定的编码?
发布于 2014-10-08 14:55:49
多亏了莫比磁盘,我找到了解决方案。在将注释编码到您使用的注释之前,您需要得到正确的注释编码(在我的示例中是默认的)。
守则如下:
using (ZipFile zipFile = new ZipFile(path))
{
byte[] bytes = Encoding.GetEncoding(437).GetBytes(zipFile.Comment);
comment = Encoding.Default.GetString(bytes);
}
https://stackoverflow.com/questions/26258196
复制相似问题