Post by matthewj on Nov 30, 2005 13:33:17 GMT -5
Hi,
I'm just evaluating the VCLZip component (in Delphi 7), but am having a problem with ZLibDecompressString. The problem is that it isn't returning the result, but is instead altering the original string.
Perhaps this is fixed in 3.06, but the code below my signature shows the problem easily in the debugger. Set it up to show all the strings in the watch window, and then you will see at the marked line that the
result is very wrong.
I checked the forums but this is not mentioned. I look forward to a speedy response so I can complete my testing and buy it.
Yours,
Matthew Jones
Oops - I forgot that the decode is needed. This is a base64 encoding so that I can store the text in XML. You can use the following and it still shows the problem:
Note also that the szDecoded string has original junk at the end. Looks
to me like the SetLength is used on the result, but the values written
to the parameter.
I'm just evaluating the VCLZip component (in Delphi 7), but am having a problem with ZLibDecompressString. The problem is that it isn't returning the result, but is instead altering the original string.
Perhaps this is fixed in 3.06, but the code below my signature shows the problem easily in the debugger. Set it up to show all the strings in the watch window, and then you will see at the marked line that the
result is very wrong.
I checked the forums but this is not mentioned. I look forward to a speedy response so I can complete my testing and buy it.
Yours,
Matthew Jones
procedure TestCoding;
var
xZipper : TVCLZip;
szDecoded : string;
szFinal : string;
szOriginal : String;
szCompressed : string;
szZipped : string;
begin
szOriginal := 'hello mum how are you today';
xZipper := TVCLZip.Create(nil);
try
szZipped := xZipper.ZLibCompressStr(szOriginal, false);
szCompressed := EncodeLine(szZipped);
finally
FreeAndNil(xZipper);
end;
xZipper := TVCLZip.Create(nil);
try
szDecoded := DecodeLine(szCompressed);
// breakpoint on the next line, and watch what happens to the
variables!
szFinal := xZipper.ZLibDecompressString(szDecoded, false);
finally
FreeAndNil(xZipper);
end;
assert(szFinal = szOriginal);
end;
Oops - I forgot that the decode is needed. This is a base64 encoding so that I can store the text in XML. You can use the following and it still shows the problem:
function EncodeLine(szValue : string) : string;
begin
result := szValue;
end;
function DecodeLine(szValue : string) : string;
begin
result := szValue;
end;
Note also that the szDecoded string has original junk at the end. Looks
to me like the SetLength is used on the result, but the values written
to the parameter.