PHP (gzcompres) sıkıştırılmış QT / C + + veri sıkıştırmasını nasıl

2 Cevap php

Ben PHP gzcompress ($ string) tarafından yazılmış bir sıkıştırılmış dize var

Ben QT C + + ile okumak gerekir.

Herhangi bir yardım çok takdir!

2 Cevap

You can use qUncompress: http://doc.trolltech.com/4.6/qbytearray.html#qUncompress
Please note that you need to prepend the expected uncompressed length.

Örnek kod (C + +) ile:

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.

PHP fonksiyonları gzcompress / gzuncompress için analog ZLIB olduğunu. Bu python mevcuttur ve c++ - orada dekompresyon için işlevleri bulabilirsiniz.