iprintf etc. don't print chars > 0x7F ?
Posted: Mon Dec 07, 2009 11:37 am
I'm writing a iprintf-like function for printing text using a 8x16 font to a text background.
My font contains the standard ASCII character set for codes 0-127 and language specific
characters starting at 128, e.g. german umlauts:
128 = 'ä', 129 = 'ö', 130 = 'ü' (and so on)
However, output is stopped, whenever a character > 127 is encountered. For parsing the
format string and ellipsis I use vsiprintf.
Code:
Function call: Print the word "Zurück" (german for "back").
A console is init'd on the sub screen, regular output goes to main screen.
Result:
Line 1 is what is passed to TextPrint (without inserting arguments)
Line 2 is the result of vsiprintf
Both lines include hex output in []
Funnily enough, output is correct, when Format is printed via "%s" (Line 1)...
I confirmed that also iprintf, printf, sprintf and siprintf produce the same result.
On Win32 (DevCpp/MingW), (at least) printf produces correct results.
Code:
Result:
(prints "é" instead of "ü" because the charset is different)
http://ryouarashi.ry.funpic.de/error2.png
Is this a bug or intended behaviour?
My font contains the standard ASCII character set for codes 0-127 and language specific
characters starting at 128, e.g. german umlauts:
128 = 'ä', 129 = 'ö', 130 = 'ü' (and so on)
However, output is stopped, whenever a character > 127 is encountered. For parsing the
format string and ellipsis I use vsiprintf.
Code:
Code: Select all
char TextBuffer[2048];
int TextPrint(const char * Format, ...)
{
va_list args;
va_start(args, Format);
int N = vsiprintf(TextBuffer, Format, args);
va_end(args);
// some debug output:
iprintf("1:%s [", Format);
for (int j = 0; Format[j] != 0; j++) iprintf("%.2x", Format[j]);
iprintf("]\n2:%s [", TextBuffer);
for (int j = 0; TextBuffer[j] != 0; j++) iprintf("%.2x", TextBuffer[j]);
iprintf("]\n");
/* Output to selected background omitted here */
return N;
}
A console is init'd on the sub screen, regular output goes to main screen.
Code: Select all
unsigned char test[] = {'Z', 'u', 'r', 0x82, 'c', 'k', 0};
TextPrint((const char *)test);
Line 1 is what is passed to TextPrint (without inserting arguments)
Line 2 is the result of vsiprintf
Both lines include hex output in []
Funnily enough, output is correct, when Format is printed via "%s" (Line 1)...
I confirmed that also iprintf, printf, sprintf and siprintf produce the same result.
On Win32 (DevCpp/MingW), (at least) printf produces correct results.
Code:
Code: Select all
#include <stdio.h>
#include <stdlib.h>
int main(int argc, char *argv[])
{
unsigned char test[] = {'Z', 'u', 'r', 0x82, 'c', 'k', 0};
printf((const char *)test);
printf("\n");
system("PAUSE");
return 0;
}
(prints "é" instead of "ü" because the charset is different)
http://ryouarashi.ry.funpic.de/error2.png
Is this a bug or intended behaviour?