This project is read-only.

multi-char comment partly disappeared

Nov 4, 2008 at 2:12 AM
great honor to your wonderful job first!
recently i picked up the library in my software to archive some project folders, since then i found a small problem with it.
just as the head of my post mentions, some words at the end of the zip file's comment lost.
when i looked into the source, i thought it maybe just a historical negligence while dealing with multi-char words.
there is a byte space allocation statement:
    if (Comment != null) bufferLength += Comment.Length;
    byte[] bytes = new byte[bufferLength];
well, this works well with one-char characters, but when coming to multi-char words, there wont be enough space to store them, so some words would be cast out.
so i made some small tune-ups to the code, moved statement
    byte[] block = SharedUtilities.StringToByteArray(Comment, Encoding);
to the head of the function, before the space allocation
and modified the way of space calculation
    if (Comment != null) bufferLength += Comment.Length;
==> if (Comment != null) bufferLength += block.Length;
then, the problem is fixed up, your library works fine all.
once again thanks to you and your great work, it helps a lot!

Nov 4, 2008 at 6:59 AM
Edited Nov 4, 2008 at 6:36 PM
yes, that's a good catch. thanks.

Nov 4, 2008 at 8:20 PM
I updated the v1.6 release to properly support multi-byte charsets in the ZipFile.Comment.