I compile the following code in Microsoft Visual Studio 2008:
#include <windows.h>
int WINAPI
WinMain(HINSTANCE hInst, HINSTANCE hPrev, LPSTR lpCmdLine, int nCmdShow)
{
MessageBox(NULL, "Hello World", "Notes!", MB_OK);
return 0;
}
And the output is in some crazy moon runes that I don't understand (east-asian characters), rather than the plain "Hello World" I was expecting. What gives?
Name:
Anonymous2009-02-19 15:39
You are compiling with unicode support and Windows interprets your ASCII string as an UTF-16 string.
Name:
Anonymous2009-02-19 15:41
>>2
Any idea how I get rid of said unicode support? Or perhaps, how to keep the unicode support in and change my strings to UTF-16?
Name:
Anonymous2009-02-19 15:43
L"Hello World", L"Notes!"
Name:
Anonymous2009-02-19 15:45
>>2
Oddly, the compiler should catch that particular error, though it does sound like it might be the case.
OP, What is your default system locale set to? (see "Language for non-Unicode programs" in Regional and Language options)
>>5
system locale is set to swedish, and swedish is used for non-unicode programs, the OS is Windows 7. I did realize it might've had something to do with unicode support after checking what the compiler was doing with my code, but I didn't understand why.
And the compiler didn't say a thing about it.
Name:
Anonymous2009-02-19 16:12
Harry Potter is a fictional story about fictional magic.
SICP is a real book about real magic.
Name:
Anonymous2009-02-19 16:16
Don't you have to define UNICODE before the win32 API gives you unicode support?
Name:
Anonymous2009-02-19 16:18
>>8
Is that even relevant to the conversation, or is it just your way of saying "I've read Harry Potter"?
Name:
Anonymous2009-02-19 16:30
>>9
I have no idea, but apparently that wasn't necessary in my case. I may have accidentally told visual studio somewhere that I wanted unicode support in projects I create myself, and it proceeded to add it in for me (in my case, all it really did was add a few lines to the compilers' commandline options).
Name:
Anonymous2009-02-19 17:55
IIRC use MessageBoxA, or something like that, and it'll work.
It's been a long time since I had the misfortune of developing on Windows, though.
>>13
Unicode support is fine as long as it doesn't cause me unnecessary headaches. In this case, it caused me headaches until >>2 explained what was going on, which I am ever so grateful for.
>>22
It seems MS changed the default API type mode used by the compiler from ANSI to UNICODE/ ( It uses *W instead of *A now )
The functionality has always been available, just the default used to be ANSI.