[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-core-devel
Subject:    Re: Data types for KCodecs (Re: kdenetwork/kmail)
From:       Dawit Alemayehu <adawit () kde ! org>
Date:       2001-12-27 21:44:50
[Download RAW message or body]

On Thursday 27 December 2001 14:42, Michael Häckel wrote:
> On Thursday 27 December 2001 20:10, Dirk Mueller wrote:
> > On Mit, 26 Dez 2001, Michael Haeckel wrote:

> The binary data should always be in a QByteArray and not sometimes in a
> QCString or QString.

IMHO you are only approaching this from the aspect of encoding/decoding 
binary data.  There are many circumstances where I want to encode a string
and have the result return on a NULL terminated string.  For example, basic
authentication in kio_http.  As such the two current functions that return
a QCString are intended to reduce the number errors that might occur if 
people are not careful when using the API.  Again using the above example,
if I simply convert the returned QByteArray into char* and assign it to a varible
the result will be corrupted since the encoded text was not properly NULL terminated!

> The encoded data should be either in a QByteArray of a QCString.
>
> So functions like the following for all encoding types should be enough:
>
> static QCString base64Encode(const QByteArray& in, bool insertLFs = false)
> static void base64Encode(const QByteArray& in, QByteArray& out, bool
> insertLFs = false)
>
> static QByteArray base64Decode(const QCString& in)
> static void base64Decode(const QByteArray& in, QByteArray& out)

See above why this is a bad deal if someone is not careful.  Whenever
you are encoding and decoding binary data, you should simply use

static void base64Encode(const QByteArray& in, QByteArray& out, bool, insertLFs = false)

period.  Otherwise, use one of the other two functions should be used.  Specially,
if you need a null terminated text!  I thought this was straight forward enough ??

> Everything with QString can leave totally.

I am removing all of these tomorrow since they were left there for BC purposes and
are no longer necessary!  

Would this resolve the issue for you ?

Regards,
Dawit A.

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic