Degree Celsius Crash -> º

insider

10-02-2015 04:18:26

How do I get MyGUI to display º the symbol for degree ?
It crashes on MyGUI::utility::toString('\xba')
But something like MyGUI::utility::toString('\x5e') for ^ works fine

Degree symbol is 167 in ASCII and ba in hex.

Edit:
Typing it directly crashes too MyGUI::utility::toString('º')

Any ideas?

Altren

10-02-2015 15:07:44

Does MyGUI.log have any errors? Usually unknown characters are replaced with special symbol (looks like rectangle) or with space. You need to have given character in font definition, if it is not in range it won't be generated in font texture, but the crash should not happen anyway.

Edit: I think crash happens because you use non-utf8 charater, that's what MyGUI::UString expect.

insider

10-02-2015 23:50:41

There are no errors in MyGUI log and yes it is a non-utf8 character.
Is there any way I can display it :)
Or can we expect support for non-utf8 characters in future MyGUI versions :D

Altren

12-02-2015 16:02:53

Use utf8 code for this character and it will be displayed.

insider

14-02-2015 00:24:11

Use utf8 code for this character and it will be displayed.

And what exactly is the utf8 code for º ? :?

insider

14-02-2015 00:37:41

Use utf8 code for this character and it will be displayed.

And what exactly is the utf8 code for º ? :?


Never mind, I got it working through Boost :D

#include <boost/locale.hpp>

unsigned int point = 0xba; //Hex for º
std::string utf8 = boost::locale::conv::utf_to_utf<char>(&point, &point + 1);
tempText->setCaption(MyGUI::utility::toString(utf8)); // Displays º in MyGUI


Note to self and others having the same issues
For users who are having similar issues incase an invalid character is displayed (like a rectangle) goto MyGUI_Font.xml and set the code range for your font to <Code range="0 255"/> from the default <Code range="32 126"/>