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 26 Mar 2016, 01:32 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 26 Mar 2016, 02:02
    0
    • B buckler
      26 Mar 2016, 01:32

      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 26 Mar 2016, 02:02 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 26 Mar 2016, 13:25 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 26 Mar 2016, 17:12
        0
        • B buckler
          26 Mar 2016, 13:25

          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 26 Mar 2016, 17:12 last edited by
          #4

          @buckler The following should do, too:

          QString::fromUtf8("Some text \u25c0");
          
          B 1 Reply Last reply 27 Mar 2016, 00:34
          0
          • ? A Former User
            26 Mar 2016, 17:12

            @buckler The following should do, too:

            QString::fromUtf8("Some text \u25c0");
            
            B Offline
            B Offline
            buckler
            wrote on 27 Mar 2016, 00:34 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 27 Mar 2016, 01:03
            0
            • B buckler
              27 Mar 2016, 00:34

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

              ? Offline
              ? Offline
              A Former User
              wrote on 27 Mar 2016, 01:03 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

              6/6

              27 Mar 2016, 01:03

              • Login

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