Qt quncompress gzip data

前端 未结 3 2047
遥遥无期
遥遥无期 2020-12-10 04:51

I stumble upon a problem, and can\'t find a solution.

So what I want to do is uncompress data in qt, using qUncompress(QByteArray), send from www in gzip format. I

3条回答
  •  余生分开走
    2020-12-10 05:17

    You also forgot dataPlusSize.append(data);. However, that won't solve your problem. The problem is that while gzip and zlib have the same compressed data format, their headers and trailers are different. See: http://www.zlib.net/zlib_faq.html#faq18

    qUncompress uses the zlib uncompress, so it can only handle the zlib format, not the gzip format. It would need to call the gzXXXX functions to handle the gzip format.

    The reason that qUncompress can handle output from PHP's gzcompress is that gzcompress compresses the given string using the ZLIB data format. See: http://php.net/manual/en/function.gzcompress.php

    As CiscoIPPhone mentioned, you'll need to write your own to functions to handle gzip data.

提交回复
热议问题