warning C4819: How to find the character that has to be saved in unicode?

后端 未结 5 1850
太阳男子
太阳男子 2021-01-30 22:57

I have seen the following warning recently through my VS2010.

Warning 21 warning C4819: The file contains a character that cannot be represented in the current code pag

相关标签:
5条回答
  • 2021-01-30 23:44

    at line 176:

    BOOST_ASSERT(0); // §27.4.3.2 allows undefined-behaviour here
    

    You see, there is a character before 27 in the above line.

    0 讨论(0)
  • 2021-01-30 23:50

    I met this problem in my project and tried to modify all non-unicode characters. But I had to give up and found a another way, as there were too many files with such problem (even though all of them are in comments).

    Then I found a quick way to fix this by setting 'system locale'.

    Control Panel -> Clock,Language,and Region -> Region and Language -> 
    Administrative -> Language for non-Unicode programs -> Change system locale -> English
    

    I think this could fix your problem if your 'system locale' is not English.

    https://stackoverflow.com/a/37871883/3148107

    0 讨论(0)
  • 2021-01-30 23:58

    You can use the regex shown above in Visual Studio to locate those characters. Here is the Regex: [^\x00-\x7F]

    0 讨论(0)
  • 2021-01-30 23:59

    You can use Notepad++ to find all Unicode characters in a file using a regular expression:

    1. Open your file in Notepad++.
    2. Ensure that you select UTF-8 from the Encoding menu.
    3. Open the search box (use CTRL-F or go to the Search menu and select Find...).
    4. Under Search Mode, select the radio button for Regular expression.
    5. Enter [^\x00-\x7F] in the Find what box and hit the Find Next button to see what you get.

    After you find the Unicode character(s), you can remove/change them, change the encoding back to ANSI, and save the file.

    You don't have to use Notepad++, of course. The RegEx will work in other text editors, e.g., Sublime Text.

    0 讨论(0)
  • 2021-01-31 00:04

    Basically, you might have compiled a file which is encoded in another charset that is not the default charset of your operating system. One way is to delete those characters that can not decoded by your default encoding, but I prefer the other way which is just using Notepad++ to trans-coding your file. To achieve this goal, click Encoding->Convert To xxx, where xxx is your operating system default encoding.

    0 讨论(0)
提交回复
热议问题