Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-38553

QString::fromLatin1 does not copy byte arrays containing 0-bytes correctly

    XMLWordPrintable

Details

    • Bug
    • Resolution: Invalid
    • Not Evaluated
    • None
    • 5.1.1
    • None

    Description

      If I want to copy a byte array that contains 0-bytes into a string using the method "QString::fromLatin1", the 0-byte ad the characters behind the 0-byte are cut off.

      Example:

      QString sInput = "426567696e00456e64"; // --> "Begin\0End"
      QByteArray ba = QByteArray::fromHex(sInput.toLatin1());
      QString sRes = QString::fromLatin1(ba); // --> DOES NOT WORK CORRECTLY

      // --> sRes = "Begin"; "\0End" is missing !!!

      Additional Info - following works:
      QString::fromLatin1(ba.constData(), ba.size());

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            thiago Thiago Macieira
            tneuhofer Thomas Neuhofer
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes