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

Qt 4.x does not seem to properly handle some Unicode characters

    XMLWordPrintable

Details

    • Bug
    • Resolution: Cannot Reproduce
    • Not Evaluated
    • None
    • 4.8.5
    • None
    • Gentoo, x86-64

      Qt version 4.8.5
      GCC version 4.7.3

    Description

      I was playing around with some string processing code and ran into a rather frustrating problem. Qt 4.x doesn't seem to handle Unicode properly. Consider the following code snippets:

      QString s;
      s.append(QChar(0xD801)).append(QChar(0xDC80));
      qDebug() << s;
      

      I expect that this will print out a string containing the Unicode codepoint: 0x10480. It does not. I wanted to find out if the problem was in QString or QChar, so I also tried this code:

      quint32 cp[] = { 0x10480  };
      s = QString::fromUcs4(cp, 1);
      qDebug() << s;
      

      This also failed to print the expected string.

      It is worth noting that both of these snippets do work on Qt 5.1, but fails to work correctly with 4.8.

      At first, I thought it was a problem with surrogates. But even this snippet won't display the expected string:

      QString s;
      s.append(QChar(0x124B));
      qDebug() << s;
      

      I suppose it's possible that this is an environment issue. But I don't know of any compilation flags for Qt which would effectively stop Unicode support from working correctly.

      Attachments

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

        Activity

          People

            laknoll Lars Knoll
            eteran Evan Teran
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes