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

[Reg 5.15.2 -> 5.15.10, 6.3.1] Change in QString::asprintf() behaviour

XMLWordPrintable

      Code

      const char *rawBytes = u8"你好世界!";
      int nChars = 5;
      QString str = QString::asprintf("%-*.*s", nChars, nChars, rawBytes);
      
      qDebug().noquote() << rawBytes;
      qDebug().noquote() << str;
      qDebug().noquote() << QByteArray(rawBytes).toHex(' ');
      qDebug().noquote() << str.toUtf8().toHex(' ');
      

       

      Output for Qt 5.15.2 (expected)

      你好世界!
      你好世界!
      e4 bd a0 e5 a5 bd e4 b8 96 e7 95 8c ef bc 81
      e4 bd a0 e5 a5 bd e4 b8 96 e7 95 8c ef bc 81
      

       

      Output for Qt 5.15.10 and 6.3.1 (unexpected)

      你好世界!
      你��  
      e4 bd a0 e5 a5 bd e4 b8 96 e7 95 8c ef bc 81
      e4 bd a0 ef bf bd ef bf bd 20 20
      

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

            thiago Thiago Macieira
            skoh-qt Sze Howe Koh
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved:

                There are no open Gerrit changes