Display Chinese in VC++ 6

Nov 12, 2012 at 9:10am
I have a game source code that has been built in VC++ 6. Problem is when I try to display a Chinese message in a message box (that is customized message box to display in game interface), but the Chinese message is always broken. This is function:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
BOOL Message_Box(char * msg, int Button, void (*pProcOK)(), void (*pProcCancel)()){
  CMsgDlg dlg;
  int nCnt = 100;
  int nIndex = 0;
  do {
    nIndex = FindMsgDlg(nCnt);
    if(nIndex == -1)
      break;
    nCnt++;
  } while(true);
  dlg.SetDlg(g_hMainWnd, nCnt, Button, msg, pProcOK, pProcCancel);
  g_vtDlgList.push_back(nCnt);
  g_vtMsgBox.push_back(dlg);
  ShowDlg(dlg.GetIndex());
  return FALSE;
}


How can I call?

Message_Box("你没有足够的钱进入房间。", MB_OK);
And this is result when it displays on message box:

??有足?的??入房?

Can somebody give me some idea?
Thank you so much.
Nov 12, 2012 at 9:30am
the chinese character set cannot be represented using the ANSI version of the API. You need to use the UNICODE version. i.e. wchar_t instead of char and L"..." instead of "..."

Change your project settings to UNICODE
Last edited on Nov 12, 2012 at 9:31am
Nov 12, 2012 at 9:50am
Thanks for your answer.
Could you explain to me more about how can I change project settings to Unicode? Do you mean that changing format of .cpp file when saving?
Nov 12, 2012 at 10:00am
Look into the MSDN documentation, if you have it installed.

And if you can't find relevant settings, I suggest you reinstall VC++ 6.0, and be sure to select the Unicode MFC libraries. Because they are unchecked in a default setup, I think.

http://stackoverflow.com/questions/10492690/did-visual-c-6-0-support-unicode

Also be sure to use the latest service pack:
http://www.microsoft.com/en-us/download/details.aspx?id=9183
Nov 12, 2012 at 10:25am
The problem is that VC++6 is pretty old. Better get a more recent version like vc++2008 (there you're indeed able to choose the code page -> "Advanced Save option")

Look at this

http://stackoverflow.com/questions/10494859/check-whether-a-visual-c-6-0-project-did-support-unicode-or-not

to find out how to change the project settings vor vc++6

Topic archived. No new replies allowed.