From: George F. <gf...@us...> - 2000-12-22 14:54:46
|
On Fri, Dec 22, 2000 at 03:23:09PM +1100, Andrew Durdin wrote: > I'm experiencing a strange problem: I'm using a font which uses the upper > ascii codes for special symbols (e.g. 0x89 is a circle), and when I print > individual characters with textprintf( ..., "%c", 0x89 ) it works fine, but > if I use textout( ..., "\x89", ... ) or textprintf( ..., "%s", "\x89" ) all > I get is a caret (^). Why is this? In short, Allegro uses Unicode. The default mode is (I think) UTF-8, in which the lower ASCII codes remain the same but the higher codes are escape sequences for multi-byte characters. At a guess, your first example worked because Allegro knows that %c takes an integer (not just a char), and uses the whole integer as the code for the character, bypassing the UTF-8 decoding, while the next two both print strings which contain this data: 0x89 0x00. The 0x89 is an escape character, and the 0x00 is a premature end of string, so Allegro prints a caret (the default character for when the data is invalid or the character does not exist in the font). I don't know how much help that is to you though. :) You can put Allegro into ASCII mode if you like, or use the Unicode routines to convert your string to the current text format. I don't think it's advisable to try to write UTF-8 code by hand. George -- Random project update: 22/06/2000: AllegroGL documentation: http://allegrogl.sourceforge.net/ See under `Documentation' for the AllegroGL Reference Manual in various formats. |