-1

I have a file that contains Strings like:

444541191800B45D01FF00004593244700013030303535202

I think that these are unicode strings. How can i convert them to a Qt QString object? I tried the following:

QByteArray ar1 = inQString.toAscii();
QByteArray ar2 = QByteArray::fromHex(ar1);
QString outQString = QString::fromUtf8(ar2.data());

But his returns a String with only 5 Characters.

drescherjm
  • 10,365
  • 5
  • 44
  • 64
RED SOFT ADAIR
  • 12,032
  • 10
  • 54
  • 92

1 Answers1

1

I just found the solution myself. The size parameter was missing. Correct Code:

QByteArray ar1 = inQString.toAscii();
QByteArray ar2 = QByteArray::fromHex(ar1);
QString outQString = QString::fromUtf8(ar2.data(), ar2.size());
eyllanesc
  • 235,170
  • 19
  • 170
  • 241
RED SOFT ADAIR
  • 12,032
  • 10
  • 54
  • 92