Writing a sample code file that compiles in all systems.


If you write a file that is intended to compile in all systems (ue, sample code file), people who compile it in a code page different than the code page that is was saved under may encounter a compiler error: "C4819: The file contains a character that cannot be represented in the current code page (System_code_page). Save the file in Unicode format to prevent data loss".

To write a C code file that compiles on all systems, you have 2 options:

1- save it in unicode (will not compile using older compilers though)

2- or if you want to support all compilers including older ones, change the following:

 const static char mb_japanese[] = "....";
 to
 const static char mb_japanese[] = { 0x41, 0xF0, 0x72, 0xFD,  0};
 
this method should be done for all string types, including wchars.
 
Comments (0)

Skip to main content