Just to be clear: my point was NOT about using a temp objects.
Back to our discussion:
The data buffer in the temporary QByteArray is a transformed copy of the data buffer that is in the string's buffer.
I just checked and you are right:
toAscii() (via toLatin1()) indeed transforms the data:
{
if (d->size) {
ba.resize(d->size);
const ushort *i = d->data;
const ushort *e = d->data + d->size;
uchar *s = (uchar*) ba.data();
while (i != e) {
*s++ = (*i>0xff) ? '?' : (uchar) *i;
++i;
}
}
return ba;
}
QByteArray QString::toLatin1() const
{
QByteArray ba;
if (d->size) {
ba.resize(d->size);
const ushort *i = d->data;
const ushort *e = d->data + d->size;
uchar *s = (uchar*) ba.data();
while (i != e) {
*s++ = (*i>0xff) ? '?' : (uchar) *i;
++i;
}
}
return ba;
}
To copy to clipboard, switch view to plain text mode
One of the main disadvantages answering such post during work is that I can often just skim the posts. :-\
Bookmarks