开发者

How can I get Visual Studio 2010 to show Chinese comments properly

I have some code from a Chinese business partner, and all of the comments in the code are in Chinese. However, Vis开发者_如何学编程ual 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...


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.


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.


For 2021 Chinese reader using Visual Studio 2019:

On Windows, the Visual Studio 2019 Community is default to use Big5 encoding.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜