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

visual-studio-2010

Solution

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

- Open your file in Notepad++.

- Ensure that you select UTF-8 from the Encoding menu.

- Open the search box (use CTRL-F or go to the Search menu and select Find...).

- Under Search Mode, select the radio button for Regular expression.

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

Problem

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 page (936). Save the file in Unicode format to prevent data loss ``` c:\boost\vs2010_boost1.49\include\boost\format\alt_sstream_impl.hpp 1 ``` Based on MSDN, the file contains a character that has to be saved in unicode format. Question: I didn't touch those files myself. Is there a way that I can find those characters and correct it manually. In other words, I don't want to save the source file in unicode format. Thank you

Original source