Archived

This topic is now archived and is closed to further replies.

Castaway

WriteConsole() and non-ascii characters

Recommended Posts

Castaway    122
Okay, I am trying to write a roguelike game on Win32 console (using MSVC6) and have a seemingly trivial problem. I''m trying to print out non-ascii characters (such as a and o umlauts, or ä and ö ), but get garbage instead. For example: char *str; str = "ÄäÖö"; WriteConsole(hStdout, str, strlen(str), &result, NULL); This works fine for characters from a to z but when encountering aforementioned special characters the function just handles them in its own way. I suspect that the problem might lie in that the function expects to get characters whose ascii value is less than 128 (signed char). Obviously, the characters I have problems printing have ascii values greater than that, e.g. ä has an ascii value of 196, but it gets converted to -60. I have tried to make a casts to unsigned char in various different places but so far been unsuccessful with it. I thought there would be an easy answer to this by setting the codepage with SetConsoleOutputCP(), but no matter what codepage I try (I guess 850 should work fine for me), the same garbage gets displayed. I''m starting to get fed up with this nasty little thingy. Any help would be much appreciated... thanks in advance.

Share this post


Link to post
Share on other sites
spock    217
I''ve never played with WriteConsole() et al, but I suspect the problem may be that it expects ANSI characters rather than characters of some extended ASCII codepage.

Share this post


Link to post
Share on other sites