gbadev.org forum archive

This is a read-only mirror of the content originally found on forum.gbadev.org (now offline), salvaged from Wayback machine copies. A new forum can be found here.

C/C++ > printf/iprintf only prints first 128 characters

#164790 - Chano Marrano - Fri Nov 21, 2008 12:13 pm

I'm using devKitPro r23b. In r18 version printf could print characters such as '?', '?' and '?', but now it only prints the first 128 ascii characters. An example:

siprintf(text, "I have %d $. Good!\n", 2);
Output: I have 2 $. Good!

siprintf(text, "I have %d ?. Good!\n", 2);
Output: I have 2

Any ideas?
_________________
Sh*tty RPG

#164792 - Ludo6431 - Fri Nov 21, 2008 12:39 pm

All the caracters are printed but when you type '?' in your charset, '?' is not a unic caracter, i think '?' use 2 caracters to be coded in the file (and i think the first caratcer is '\0').

To print your '?' you should get the ascii code of '?' in an ascii table and put \xXX instead of your ? (where XX is the hexa ascii code).

#164793 - kusma - Fri Nov 21, 2008 1:00 pm

Ludo6431 wrote:
To print your '?' you should get the ascii code of '?' in an ascii table and put \xXX instead of your ? (where XX is the hexa ascii code).

'?' is not an ASCII-character, so you won't find it in the ASCII-table.

#164794 - Chano Marrano - Fri Nov 21, 2008 1:21 pm

Sorry, bad example. Another:

siprintf(text, "Pokemon!\n");
Output: Pokemon!

siprintf(text, "Pok?mon!\n");
Output: Pok

'?' character is in the most popular ascii extended table, and as I said before it worked with devKitArm r18.
_________________
Sh*tty RPG

#164796 - sverx - Fri Nov 21, 2008 2:15 pm

maybe it's your source editor that doesn't save your source in the correct way?

#164797 - Cearn - Fri Nov 21, 2008 3:14 pm

The stdio functions of DKA r22 and up use UTF-8 instead of extended ascii. It appears that invalid UTF-characters (like a single character between 128-255) are seen as terminators, so you need the full UTF-8 characters.

Note that the current libgba and libnds console routines do not have UTF-decoder parts, so in all likelihood you won't be able to render the upper ascii characters with them unless you roll your own.

#164799 - Chano Marrano - Fri Nov 21, 2008 4:06 pm

Ouch... thanks, Cearn.

Anyway, posprintf keeps printing extended ASCII characters as expected (now I only need vposprintf xP).
_________________
Sh*tty RPG