Win32 Program Shows Oriental Characters

I am trying to learn how to use the Windows API, and I keep running into road blocks.

Here is the simple code I am using:
1
2
3
4
5
6
7
8
#include <windows.h>

int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, 
    LPSTR lpCmdLine, int nCmdShow)
{
    MessageBox(NULL, "Goodbye, cruel world!", "Note", MB_OK);
    return 0;
}


It works in Dev-C++. In Visual C++ 2008 Express Edition, it compiles successfully, but when I run it it displays weird Japanese-looking stuff instead of English text.

I like working with Visual C++ better, which is why I want to fix this. I am getting annoyed though at all the problems I'm encountering.

Does anyone know how to fix this? Thank you.
Last edited on
try:
1
2
3
4
5
6
7
8
#include <windows.h>

int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, 
    LPSTR lpCmdLine, int nCmdShow)
{
    MessageBox(NULL, L"Goodbye, cruel world!", L"Note", MB_OK);
    return 0;
}

the L is outside the string.

if it doesnt work check the your language options and Unicode character set in the project properties.

Jeff
Thanks, Jeff.

It works now.
I read a description of what the L does, but I don't really understand... isn't it just making the code less portable between compilers?
Hmm, for windows. the answer is no.
With the L you are telling the compiler that it is a wide character string. C++ uses 8 bit unicode char, while windows uses 16 bit unicode. But yeah you could just change the project properties like i said on my first post. change the charatcer set to Use Multi-Byte Character Set.

May not be the your case but some people fail to understand that:
 
c++ != windows;

Both has its own standards

Detailed info can be found on this article by Jason Orendorff:
http://www.jorendorff.com/articles/unicode/windows.html

and of course the msdn:
http://msdn.microsoft.com/
Topic archived. No new replies allowed.