title: Delphi XE and ZLib Problems
body: <p>I'm in Delphi XE and I'm having some problems with ZLib routines...</p>
  
  <p>I'm trying to compress some strings (and encode it to send it via a SOAP webservice -not really important-)</p>
  
  <p>The string results from ZDecompressString differs used in ZCompressString.</p>
  
  <p>example1:</p>
  
  <pre><code>uses ZLib;
  // compressing string
  // ZCompressString('1234567890', zcMax); 
  // compressed string ='xÚ3426153·°4'
  
  // Uncompressing the result of ZCompressString, don't return the same:
  // ZDecompressString('xÚ3426153·°4'); 
  // uncompressed string = '123456789'
  
  if '1234567890' &lt;&gt; ZDecompressString(ZCompressString('1234567890', zcMax)) then
    ShowMessage('Compression/Decompression fails');
  </code></pre>
  
  <p>example2:</p>
  
  <pre><code>Uses ZLib;
  // compressing string
  // ZCompressString('12345678901234567890', zcMax) 
  // compressed string ='xÚ3426153·°40„³'
  
  // Uncompressing the result of ZCompressString, don't return the same:
  // ZDecompressString('xÚ3426153·°40„³') 
  // uncompressed string = '12345678901'
  
  if '12345678901234567890' &lt;&gt; ZDecompressString(ZCompressString('12345678901234567890', zcMax)) then
    ShowMessage('Compression/Decompression fails');
  </code></pre>
  
  <p>the functions used are from some other posts about compressing and deCompressing</p>
  
  <pre><code>function TForm1.ZCompressString(aText: string; aCompressionLevel: TZCompressionLevel): string;
  var
    strInput,
    strOutput: TStringStream;
    Zipper: TZCompressionStream;
  begin
    Result:= '';
    strInput:= TStringStream.Create(aText);
    strOutput:= TStringStream.Create;
    try
      Zipper:= TZCompressionStream.Create(strOutput, aCompressionLevel);
      try
        Zipper.CopyFrom(strInput, strInput.Size);
      finally
        Zipper.Free;
      end;
      Result:= strOutput.DataString;
    finally
      strInput.Free;
      strOutput.Free;
    end;
  end;
  
  function TForm1.ZDecompressString(aText: string): string;
  var
    strInput,
    strOutput: TStringStream;
    Unzipper: TZDecompressionStream;
  begin
    Result:= '';
    strInput:= TStringStream.Create(aText);
    strOutput:= TStringStream.Create;
    try
      Unzipper:= TZDecompressionStream.Create(strInput);
      try
        strOutput.CopyFrom(Unzipper, Unzipper.Size);
      finally
        Unzipper.Free;
      end;
      Result:= strOutput.DataString;
    finally
      strInput.Free;
      strOutput.Free;
    end;
  end;
  </code></pre>
  
  <p>Where I was wrong?</p>
  
  <p>Someone else have same problems??</p>