Hey, i'm currently working on some sort of game-engine for a school project.
But i have some troubles with the al_draw_text() function. The problem is, that i can't print special characters (especially ä,ö and ü), which are used often in german.
I already tried stuff like char(129) or "\x81" but it didn't work.
I also found the function al_draw_ustr(), but i never did anything with unicode and i'm not sure how it works.
Is there a way to print these characters?
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.
This would do the same as al_draw_text(), but print the special characters?
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
2. Your font must have glyphs for those special characters
Now... you say that you tried explicit unicode characters... so perhaps it's the second issue?
When I use
al_draw_text(myFont, myColor, 42, 42, 0, "test_ä_end");
the output is just "test_". The rest is missing.
But I'm pretty sure that the font (arial.ttf) has those letters.
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?
Or any other possible solution?
Is there a way to find out?
Or any other possible solution?
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.
I just messed around a little and luckily found a solution
With the escape sequence "\u" it's possible to print the letters.
This does exactly what i wanted.
... load the strings from a separate file which is UTF-8 encoded.
Good you mentioned that.
This makes it possible to get text from files with with special characters and print it on the screen, without extra code.
Thanks for the help!