Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Unicode \u25c0 works on Mac but not Windows in button text
Forum Updated to NodeBB v4.3 + New Features

Unicode \u25c0 works on Mac but not Windows in button text

Scheduled Pinned Locked Moved Solved General and Desktop
6 Posts 2 Posters 1.8k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • B Offline
    B Offline
    buckler
    wrote on last edited by
    #1

    I need to use a Unicode character in my cross-platform application. The following code works on the Mac, but results in ? being displayed on a Windows 10 PC:
    @@
    ui->backToSurveyButton->setText("\u25C0");
    ui->continueWithAnalysisButton->setText("Proceed to Analyze \u25B6");
    @@

    Based on looking at other posts, I have tried a number of variations on this but so far no success.

    Help?
    Andy

    ? 1 Reply Last reply
    0
    • B buckler

      I need to use a Unicode character in my cross-platform application. The following code works on the Mac, but results in ? being displayed on a Windows 10 PC:
      @@
      ui->backToSurveyButton->setText("\u25C0");
      ui->continueWithAnalysisButton->setText("Proceed to Analyze \u25B6");
      @@

      Based on looking at other posts, I have tried a number of variations on this but so far no success.

      Help?
      Andy

      ? Offline
      ? Offline
      A Former User
      wrote on last edited by A Former User
      #2

      @buckler Hi! Are you sure that the symbol is in the font you're using on Windows? Is it in this list: http://www.fileformat.info/info/unicode/char/25c0/fontsupport.htm?

      1 Reply Last reply
      1
      • B Offline
        B Offline
        buckler
        wrote on last edited by
        #3

        Thank you Wieland!

        After some more digging it seemed not that the character was not in the font as much as it is 16 rather than 8 bit, QChar can do 16 bit but not the \u sequence? In any case, here is the solution that worked in the end:

        Instead of

        • ui->backToDefineButton->setText("\u25C0");
        • ui->proceedToReportButton->setText(tr("Proceed to Report \u25B6"));

        I instead coded:

        • ui->backToDefineButton->setText(QChar(0x25C0));
        • QString buttonText = tr("Proceed to Report ");
        • buttonText.append(QChar(0x25B6));
        • ui->proceedToReportButton->setText(buttonText);

        which now works on both Mac and Windows.

        Thanks for the help!
        Andy

        ? 1 Reply Last reply
        0
        • B buckler

          Thank you Wieland!

          After some more digging it seemed not that the character was not in the font as much as it is 16 rather than 8 bit, QChar can do 16 bit but not the \u sequence? In any case, here is the solution that worked in the end:

          Instead of

          • ui->backToDefineButton->setText("\u25C0");
          • ui->proceedToReportButton->setText(tr("Proceed to Report \u25B6"));

          I instead coded:

          • ui->backToDefineButton->setText(QChar(0x25C0));
          • QString buttonText = tr("Proceed to Report ");
          • buttonText.append(QChar(0x25B6));
          • ui->proceedToReportButton->setText(buttonText);

          which now works on both Mac and Windows.

          Thanks for the help!
          Andy

          ? Offline
          ? Offline
          A Former User
          wrote on last edited by
          #4

          @buckler The following should do, too:

          QString::fromUtf8("Some text \u25c0");
          
          B 1 Reply Last reply
          0
          • ? A Former User

            @buckler The following should do, too:

            QString::fromUtf8("Some text \u25c0");
            
            B Offline
            B Offline
            buckler
            wrote on last edited by
            #5

            @Wieland I had tried that, but it was not effective... it seems to need the QChar solution.

            ? 1 Reply Last reply
            0
            • B buckler

              @Wieland I had tried that, but it was not effective... it seems to need the QChar solution.

              ? Offline
              ? Offline
              A Former User
              wrote on last edited by
              #6

              Just tested it. The solution in your initial posting works for me with MinGW 32 bit but not with MSVC 2015 64 bit.

              The following works with both compilers (and also with gcc on Linux):

              ui->pushButton->setText(QString::fromWCharArray(L"\u25C0test\u25B6"));
              
              1 Reply Last reply
              0

              • Login

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • Users
              • Groups
              • Search
              • Get Qt Extensions
              • Unsolved