How can I get Visual Studio 2010 to show Chinese c

2019-08-05 13:08发布

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...

2条回答
爷、活的狠高调
2楼-- · 2019-08-05 13:27

You can use applocale, download it from here: http://www.microsoft.com/en-us/download/details.aspx?id=13209.

This is an old app but works well on Win7 and Win8 (tested). When installing, simply make sure to run it as admin. Then later on, run devnev.exe (visual studio) using applocale and set the locale to Chinese. I just tested this works perfectly well.

查看更多
Root(大扎)
3楼-- · 2019-08-05 13:46

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.

查看更多
登录 后发表回答