Questions about locale, code page, ANSI encoding in Windows systems

Source: Internet
Author: User

Recently, the code in the company code library synchronization down after compiling, unexpectedly problem. Asked the colleague said the code base certainly is no problem, and I did not change, that in the end there is a problem?

The error VS2018 reported was: Errorrc2001:newline in constant

Baidu the reason for this error, the main reason is that the definition of the string constant two quotation marks between the line, jump to the corresponding error code location, can generally resolve this compilation error. Of course, this problem is only superficial. Because code in the code base can certainly pass, and the code has been running for a long time, there is no such a low-level compilation problem.

So what's the problem?

The answer is the operating system settings. The problem stems from a historical burden on Windows itself, and I generally outline that I do not have a thorough study of the subject itself, so there are questions please understand: Generally speaking, Windows is recommended to use Unicode on the road to support internationalization, After all, a coding standard can support all the languages in the world all the text, there is no garbled and so on. But Windows also supports Unicode halfway, and has been using the Locale+ansi encoding standard before. What is this, a thing? Basically you can set the system locale by an option in the Control Panel, and the system will choose the ANSI code according to your locale (strictly speaking this can't be called Code!!). Mode (in contrast to Unicode, where the text editor, such as notepad++, VS's editor, detects that the encoding of the current text file is not Unicode), the encoding used. For example, if locale is Chinese PRC, then ANSI code is gb2312 (or GBK, anyway GB), and if Locale is English us, then ANSI encoding corresponds to extended ASCII (seemingly, no verification). To tell the truth, ANSI, the term is really painful, very confusing, because ANSI itself is a standard committee, unknown people don't know what is said.

Back to the compilation problem, since the code is usually compiled with the locale of English us, and the code file itself is not Unicode encoded, it should be encoded/decoded using extended ASCII. But because my locale is Chinese PRC, the file system for non-Unicode encoding is parsed using gb2312. Well, the problem is, the encoding and decoding of the file is incompatible with the standards used, leading to a variety of weird problems.

Here want to vomit trough Microsoft in dealing with the various tails left behind, but I said, the problem itself is too complex, solve the bad also not blame such a bloated big company, who has not a point of disease.

There are discussions on the issue of coding:

http://www.zhihu.com/question/20650946

can refer to below, may speak clearer than I.

In addition, about the locale corresponding to the ANSI code, Microsoft is called code page . The locale and code page correspondence can be found in the following:

Http://www.science.co.il/language/Locale-Codes.asp?s=codepage

http://blog.csdn.net/whygosofar/article/details/4344252

There is no time to know too much, please understand the problem.

Questions about locale, code page, ANSI encoding in Windows systems

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.