|
|
| Problem writing text with al_draw_text |
|
Cisco Mir
Member #13,959
January 2012
|
This is my code: 1bitmap = al_load_bitmap("font.pcx");
2
3int ranges[] = {0, 255};
4font = al_grab_font_from_bitmap(programa,1,ranges);
5
6al_draw_text(font,color,103,103,0,"Prova de caràcters especials: aàáÀÁ");
When it founds the first special char: "à" it stops writing text. I included those characters on my font... all the chars are there. It's al_draw_text uncapable of writing those special chars or I'm doing something absolutely wrong? In fact, the same thing happens to me with al_show_native_message_box, beeing the strings finished when some special character like á, é, í is found. I have to change the language code for the whole program or something like that? |
|
Matthew Leverton
Supreme Loser
January 1999
|
Make sure your strings are UTF-8 encoded for Allegro's text output. However, the native dialogs don't support UTF-8 (on Windows), so you'll have to use ASCII for that. |
|
AMCerasoli
Member #11,955
May 2010
|
And al_set_window_title() doesn't work with utf-8 neither...
|
|
Matthew Leverton
Supreme Loser
January 1999
|
None of the Window platform calls support UTF-8 strings. It could, but somebody would have to update Allegro to convert all 8-bit strings into 16-bit Window strings before calling the Win32 API. But al_draw_text() will work fine if given UTF-8 strings, which is mainly what this thread is about. |
|
Cisco Mir
Member #13,959
January 2012
|
Then the chars à,á,è,é,i,ï,ò,ó,ù,ú are not UTF-8? Because with al_draw_text it finishes writing when it founds a char like those ones, important chars on my language btw! |
|
AMCerasoli
Member #11,955
May 2010
|
Configure your IDE to save the document UTF-8 encoded. For example in C::B {"name":"605530","src":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/f\/e\/fe7e1946666de65c13a7c1b6af9c9693.png","w":847,"h":304,"tn":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/f\/e\/fe7e1946666de65c13a7c1b6af9c9693"}
|
|
Cisco Mir
Member #13,959
January 2012
|
The problem is solved, thank you very much! |
|
Matthew Leverton
Supreme Loser
January 1999
|
Cisco Mir said: Then the chars à,á,è,é,i,ï,ò,ó,ù,ú are not UTF-8? UTF-8 is just an encoding. Your editor was probably saving in regular "ASCII" mode. The first 127 characters are identical between UTF-8 and ASCII, which is why most of the letters were working fine. But as soon as something 128 or higher was found, it would have been an invalid UTF-8 encoding, triggering an error. |
|
|