views:

113

answers:

1

I have some code from a Chinese business partner, and all of the comments in the code are in Chinese. However, Visual Studio displays them as gibberish. How can I get them to display properly. Here is a code example with some comments converted to gibberish:

//Á¬½Óµ½·þÎñÆ÷
void CTestAPIDlg::OnBnClickedButton2()
{
    UpdateData(TRUE);
    //ÉèÖÃÊÇ·ñ¼Ç¼ÈÕÖ¾
    m_ObjRSI->EnableLog(m_bIsOnLogReg,m_bIsOnLogComm);
    //ÅжÏÊÇ·ñÆôÓôúÀí
    if (m_bIsOnProxy)
    {
        //´úÀí²ÎÊý
        char proxyIP[64];
        ZeroMemory(proxyUserPwd,sizeof(proxyUserPwd));
        //×¢£º´Ë´¦ÒòΪÊÇʹÓÃunicode±àÒ룬ËùÒÔÒª×Ö·ûת»»£¬ÏÂͬ.
        WideCharToMultiByte(CP_ACP,0,m_strProxyIP,-1,proxyIP,64,NULL,NULL);

etc...

Thanks in advance for any help...

+3  A: 

Ask your partner to save the source code file encoded in UTF-16 or UTF-8. It is still not the default encoding for C++ source code, Unicode is slow to catch up. File + Save As, click on the arrow of the Save button, Save with Encoding, choose UTF-8.

You should be able to do this yourself as well. File + Open, select the .cpp file(s), click on the arrow of the Open button, Open With, select "C++ Source Code Editor (with encoding)". Pick the correct Chinese encoding (there are several to choose from) from the Encoding dialog box.

Hans Passant
I was able to 'Open With' from Visual Studio as you suggested. Thanks.
Joe H