|
al_draw_text() and special characters |
DrFail
Member #14,578
September 2012
|
Hey, i'm currently working on some sort of game-engine for a school project. |
Arthur Kalliokoski
Second in Command
February 2005
|
I'm far from expert, but I'd think al_ustr_new_from_buffer() would work. You'd have to free the utf string yourself to avoid memory leaks. They all watch too much MSNBC... they get ideas. |
DrFail
Member #14,578
September 2012
|
1string text = "äöüÄÖÜ";
2ALLEGRO_USTR* uText = al_ustr_new(text.c_str());
3al_draw_ustr(myFont, myColor, 42, 42, 0, uText);
4al_ustr_free(uText);
This would do the same as al_draw_text(), but print the special characters? |
SiegeLord
Member #7,827
October 2006
|
al_draw_text can print special characters just fine (e.g. this is demonstrated in the ex_tff). There are two possible issues which might break it in your case. 1. Your source file must be encoded using UTF-8 Now... you say that you tried explicit unicode characters... so perhaps it's the second issue? "For in much wisdom is much grief: and he that increases knowledge increases sorrow."-Ecclesiastes 1:18 |
DrFail
Member #14,578
September 2012
|
When I use Maybe it's the first case. I'm using Dev-C++ 5.3, but i don't know if it uses UTF-8. Is there a way to find out? |
SiegeLord
Member #7,827
October 2006
|
DrFail said: Is there a way to find out? Nobody uses DevCpp, so there's no way to find out. The workabout that always works is to load the strings from a separate file which is UTF-8 encoded (you can be sure of that by using an editor that explicitly allows the option). This is in fact what ex_ttf does for MSVC compatibility. "For in much wisdom is much grief: and he that increases knowledge increases sorrow."-Ecclesiastes 1:18 |
DrFail
Member #14,578
September 2012
|
I just messed around a little and luckily found a solution 1string test = "test \u00E4\u00C4\u00F6\u00D6\u00FC\u00DC end";
2al_draw_text(font, color, 42, 42, 0, test.c_str());
This does exactly what i wanted. SiegeLord said: ... load the strings from a separate file which is UTF-8 encoded.
Good you mentioned that. Thanks for the help! |
|