![]() |
|
Alfont characters |
CursedTyrant
Member #7,080
April 2006
![]() |
It might be stupid, and it probably is, but is there any way I can get regional characters (ie. Polish "ą", "ę") working with alfont? All I get is a bunch of weird symbols. --------- |
BAF
Member #2,981
December 2002
![]() |
Are you using a font with the characters in it? |
Jakub Wasilewski
Member #3,653
June 2003
![]() |
If the answer to BAF's question is 'yes', try setting the Allegro unicode mode to... can't remember the const, I believe it's U_ASCII. EDIT: --------------------------- |
miran
Member #2,407
June 2002
|
If you use a Polish font and U_ASCII, then you basically limit your output to English (standard 7bit ASCII) and Polish with a few other languages that use the same extended ASCII layout as Polish. The prefered way is to use Unicode (the default mode which is U_UTF8 should work just fine) with a Unicode font. But then all your strings must be written in UTF8. This can be a bit tedious if you hardcode your strings in C/C++ code, because you aren't supposed to encode C/C++ source files in UTF8, so you have to use escape sequences (or whatever they're called), like in the Allegro's Unicode example. A better way is of course to write all your game strings in a separate UTF8 encoded text file, which you load in your game at start up. If you do this, it is also very easy to add support for other languages to your game. You just write a text file with strings for each language and load only one of them at runtime. -- |
CursedTyrant
Member #7,080
April 2006
![]() |
Yes, the font supports Polish characters. string buffer; ... if (keypressed()) { int scancode, c = ureadkey(&scancode); if (scancode!=KEY_BACKSPACE) { buffer += c; } else if (scancode==KEY_BACKSPACE && buffer.size()>0) { buffer.erase(buffer.size()-1, buffer.size()); } }
I've tried both readkey() and ureadkey() and I get this when typing "ąęó": --------- |
Matt Smith
Member #783
November 2000
|
Does your string class work with 32 (or 16) bit unicode? That's what ureadkey() returns. set_uformat(U_UNICODE) is what you'll need to print these strings with text_printf() etc but I don't know how alfont determines its output encoding. |
|