kio_mhtml: KCodecs::base64Decode problem
Ingo Klöcker
kloecker at kde.org
Tue Dec 21 00:38:56 GMT 2004
On Monday 20 December 2004 12:29, Spiros Georgaras wrote:
> Hi
>
> I have a problem using KCodecs::base64Decode (const QByteArray &in,
> QByteArray &out), decoding images from mhtml files.
>
> The problem is that the images I get are 1 or 2 bytes bigger than the
> original ones. The extra bytes are '/0'.
>
> My code is:
> ....
> ....
> case 1: // base64
> exC.fill(0);
> KCodecs::base64Decode(fContents,exC);
> // fContents is QCString, exC is QByteArray
> item[i].data=exC;
> item[i].decodedSize=exC.size();
> kdDebug()<<"item[i].decodedSize="<<item[i].decodedSize<<endl;
> break;;
> ....
> ....
>
> Can you help?
My guess is that the problem is caused by the trailing '\0' in the
QCString. Try something like
// copy the data of fContents to a QByteArray without the trailing '\0'
QByteArray ba( fContents.data(), fContents.length() );
KCodecs::base64Decode( ba, exC );
Regards,
Ingo
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
URL: <https://mail.kde.org/mailman/private/kfm-devel/attachments/20041221/8d025f54/attachment.sig>
More information about the kfm-devel
mailing list