How to handle foreign words in C ++ code?

Recently, I downloaded some source code in C ++, which is written in Russian. When I open a project in my MSVC (Chinese edition of VC2008), the code comments are too zealous. And when I compile the code, it generates a lot of warnings and errors. such as this case: "error C2001: new line in constant"

TCHAR text[]=_T("卿羼?η₯›ι©½?猁螯 忄 η–±θ§Œε›”?); 

I think that people who use the Windows version of Windows may not be able to handle this problem. The problem is, how can I handle foreign languages about this? I want to correctly display the code and comments in my VC ++ IDE and, thus, compile the codes, how to achieve this goal?

I'm sorry that I don’t know if I clearly explained this problem or not, and the name of this problem is correct?

+4
source share
1 answer

Try to convert all code files from CP1251 (or KOI8-R, not necessarily, you need to try) to any Unicode encoding, for example UTF-8 with specification. Notepad ++ can be used for this, but Visual Studio can also be used:

Open the files in Visual Studio, but instead of double-clicking them, do the following: right-click in the solution explorer> Open with ...> C ++ source code editor (with encoding)> "Cyrillic (Windows) - Codepage 1251" (or other cyrillic coding).

To save a Unicode-encoded file, follow these steps: File> Save As ... click on the triangle sign inside the Save button and select Save With Encoding ...> confirm overwrite> select any Unicode encoding, for example, "Unicode (UTF) -8 with signature) - Codepage 65001".

+2
source

Source: https://habr.com/ru/post/1482687/


All Articles