Problem with Wt::Chart::WCartesianChart with displaing ° in y label
Added by jakub jirsa almost 7 years ago
Hi,
I would like to write ° (degree character) next to label. I tried to use setLabelFormat(Wt::WString("%.4g °")) but it does not work it writes ?? next to Y-label.
Also I have tried to decode it straight from UTF8 but it works only with one byte encoding (ends with 0x7E which is tilde) and degree is encoded in two bytes.
Thank you very much for help.
Replies (5)
RE: Problem with Wt::Chart::WCartesianChart with displaing ° in y label - Added by Roel Standaert almost 7 years ago
Hi,
Try Wt::WString::fromUTF8
, Wt::utf8
, or Wt::WString("%.4g °", Wt::UTF8)
. The default Wt::WString
constructor uses default encoding (which defaults to C locale) instead of UTF-8.
Note also that string literals don't have a standard encoding in C. If you're using C++11, you could use u8"%.4g \u00B0"
instead.
Regards,
Roel
RE: Problem with Wt::Chart::WCartesianChart with displaing ° in y label - Added by jakub jirsa almost 7 years ago
Thank you very much for your answer however it did not help. I am still seeing ?? instead of °.
I tryed:
y1_axis.setLabelFormat(Wt::WString(".4g \u00B0",Wt::UTF8));
y1_axis.setLabelFormat(Wt::WString(".4g °", Wt::UTF8));
y1_axis.setLabelFormat(Wt::WString::fromUTF8("%.4g °"));
thanks for help
RE: Problem with Wt::Chart::WCartesianChart with displaing ° in y label - Added by Roel Standaert almost 7 years ago
What platform and compiler are you using?
Try:
y1_axis.setLabelFormat(Wt::WString(u8"%.4g \u00B0", Wt::UTF8));
Note the "u8" before the string literal.
Regards,
Roel
RE: Problem with Wt::Chart::WCartesianChart with displaing ° in y label - Added by jakub jirsa almost 7 years ago
Thanks for help but its not working. It works fine for WPushButton WLabel etc. but not for chart.
I use my raspberry pi 3.
Regards
Jacob
RE: Problem with Wt::Chart::WCartesianChart with displaing ° in y label - Added by Roel Standaert almost 7 years ago
That's strange. Can you provide a standalone program that reproduces this problem? Which version of Wt are you using? I've tested it with a recent Wt on Ubuntu 16.04, and an older Wt on Raspbian wheezy and GCC 4.6.3, and it seems to work correctly. I'm using -std=c++0x
and adding the line chart->axis(XAxis).setLabelFormat(Wt::WString(u8"%.4g \u00B0", Wt::UTF8));
to the charts example (in ScatterPlotExample::ScatterPlotExample
under chart->axis(YAxis).setLocation(ZeroValue)
.
Regards,
Roel