-3

I am making a win32 application using visual studio 2008.

When ever i compile my code which generates a simple dialog, all of the dialogs text show in Chinese language. I have not set Chinese anywhere. can some one elaborate what the issue is?

My code is

#include <windows.h>

int WINAPI WinMain(
    HINSTANCE   nowInstance,
    HINSTANCE   prevInstance,
    LPSTR   ipCmdLine,
    int     nCmdShow
    )
{
    MessageBox(NULL,"My First Program","Our University",MB_OK); 

    return 0;
}
Oded
  • 489,969
  • 99
  • 883
  • 1,009
S. A. Malik
  • 3,465
  • 6
  • 37
  • 56

1 Answers1

2

It sounds like you're mixing Unicode and ANSI.

Have you tried

MessageBox(NULL, _T("My First Program"), _T("Our University"), MB_OK);

And does that give you the expected results?

Mahmoud Al-Qudsi
  • 28,357
  • 12
  • 85
  • 125
  • You were compiled with _UNICODE set, so Windows expected all strings to be in UTF16 format, and you gave them ASCII. It's a lot like giving a float to a function expecting an int, except there's no compiler warning. – Mooing Duck Sep 26 '11 at 19:58
  • 1
    @backTangent: http://www.joelonsoftware.com/articles/Unicode.html "The Absolute Minimum Every Software Developer Absolutely, Positively Must Know About Unicode and Character Sets (No Excuses!)" – Mooing Duck Sep 26 '11 at 19:59
  • @Mooing Defining `_UNICODE` makes Windows expect strings to contain two-byte fixed width characters which is not UTF-16. The distinction is inconsequential most of the time because they are the same for most of the codepoints you'll encounter (see BMP - Basic Multilingual Plane) – IronMensan Sep 26 '11 at 20:13
  • @IronMensan: http://stackoverflow.com/questions/4592261/windows-api-ansi-and-wide-character-strings-is-it-utf8-or-ascii-utf-16-or-uc says as of Windows 2000 they accept UTF-16. However, it also says that filepaths are opaque arrays, except for uppercase/lowercase, which means the "equivalent" characters may not be treated as equivalent. – Mooing Duck Sep 26 '11 at 20:51