Unicode \u25c0 works on Mac but not Windows in button text
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->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.
@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?
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:
- ui->proceedToReportButton->setText(tr("Proceed to Report \u25B6"));
I instead coded:
- QString buttonText = tr("Proceed to Report ");
which now works on both Mac and Windows.
Thanks for the help!
@buckler The following should do, too:
QString::fromUtf8("Some text \u25c0");
@Wieland I had tried that, but it was not effective... it seems to need the QChar solution.
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):