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

QString char-pointer constructor destroys info for char values > 128

    XMLWordPrintable

Details

    • Bug
    • Resolution: Invalid
    • P1: Critical
    • None
    • 6.2.4
    • None
    • Windows

    Description

      Hallo,

      my problem for a long time now is that the QString constructor(s) that use(s) char(s) are destroying the given information of the char, if its value is above the first 128 possible ones...

      Better to show a small code snippet for that:

       

          int const len2 = 7;
          char* buf2 = new char[len2+1]();
          buf2[0]    = char(0xE4); // NOTE: Umlaut: \xE4 = 'ae'
          buf2[1]    = char(0xC4); // NOTE: Umlaut: \xC4 = 'AE'
          buf2[2]    = char(0xF6); // NOTE: Umlaut: \xF6 = 'oe'
          buf2[3]    = char(0xD6); // NOTE: Umlaut: \xD6 = 'OE'
          buf2[4]    = char(0xFC); // NOTE: Umlaut: \xFC = 'ue'
          buf2[5]    = char(0xDC); // NOTE: Umlaut: \xDC = 'UE'
          buf2[6]    = char(0xDF); // NOTE: Umlaut: \xDF = 'ss'
          buf2[len2] = '\0';
          QString     qstr2(buf2);
          QByteArray  ba2(buf2);
      

      If you stop with the debugger on the last line, you will see that all the buf2-char values get replaced with ONE WRONG FIXED value 0xfffd in the qstr2. ba2 converts all values correctly and I am sure that one should/could tell QString to convert a 0xe4 to a 0x00e4 rather than in a 0xfffd !?!

      This problem is here for a long time. I have it confirmed in Qt versions of:

      • 4.8.7
      • 5.15.2
      • 6.2.4

      It is probably present in all versions at this point. And it affects all char values above the first 128. PLEAAAASE FIX this ASAP... It has caused so many problems to us until now and the bahaviour of QString is clearly wrong.

      Thanks in advance!

      I will also attach a picture from the debugging session, to illustrate it better:

      Attachments

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

        Activity

          People

            thiago Thiago Macieira
            freeman_w Anestis Papadopulos
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes