QString::QString(const QByteArray &ba) copying full array.
-
wrote on 1 Apr 2022, 10:15 last edited by
Is there some method or contructor or function that copy from QByteArray to Qstring WHITOUT stopping at the first 0 byte??.
I need to convert QByteArray to qstring and to have a full lenght converted. Since my QByteArray contains some zeros, actrually using QString contructor from const QBytearray will truncate my QBytearray to first 0.
Is there some way to do that??Thanks
-
Is there some method or contructor or function that copy from QByteArray to Qstring WHITOUT stopping at the first 0 byte??.
I need to convert QByteArray to qstring and to have a full lenght converted. Since my QByteArray contains some zeros, actrually using QString contructor from const QBytearray will truncate my QBytearray to first 0.
Is there some way to do that??Thanks
@emazed How should the resulting string look like? I mean, what should happen with the 0 bytes?
-
wrote on 1 Apr 2022, 15:10 last edited by
const char bytes[]="Hello\0 World"; QByteArray data(bytes,sizeof(bytes)); QList<QByteArray> list=data.split('\0'); QString str=list.join(); qDebug()<<str; // -> "Hello World"
3/3