I have a compressed string written by PHP gzcompress($string)
I need to read it with C++ on QT.
Any help is very appreciated!
I have a compressed string written by PHP gzcompress($string)
I need to read it with C++ on QT.
Any help is very appreciated!
You can use qUncompress: http://doc.trolltech.com/4.6/qbytearray.html#qUncompress
Please note that you need to prepend the expected uncompressed length.
Sample code (in C++):
QByteArray aInCompBytes;
QByteArray aInUnCompBytes;
QByteArray aInCompBytesPlusLen;
int currentCompressedLen = <<read_this>>;
int currentUnCompressedLen = <<read_this>>;
aInCompBytes.resize(currentCompressedLen);
char slideStr[currentCompressedLen];
int slideByteRead = in.readRawData(slideStr, currentCompressedLen);
aInCompBytes = QByteArray(slideStr, slideByteRead);
aInCompBytesPlusLen = aInCompBytes;
aInCompBytesPlusLen.prepend(QByteArray::number(currentUnCompressedLen));
aInUnCompBytes.resize(currentUnCompressedLen);
aInUnCompBytes = qUncompress(aInCompBytesPlusLen);
The uncompressed data will be in aInUnCompBytes. You need to read/know the compressed len and uncompressed len. It wasn't tested, as I don't have Qt in my machine right now.
Best regards, T.