Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I change the code page MS Visual Studio 2008 uses to open files?

I have a cpp file that uses ibm cp437 and Visual C++ keeps reading it with windows-1252. How do I make Visual C++ use the right code page for the file?

like image 897
Spin City Avatar asked Feb 27 '23 10:02

Spin City


2 Answers

Alright, I figured it out myself. For the curious, here is the answer:

  • Right click the file in the Solution Explorer.
  • Select "Open With..."
  • Choose "C++ Source Code Editor (with encoding)"
  • A new box appears to specify Encoding. Choose "OEM United States - Codepage 437"

Done.

like image 158
Spin City Avatar answered Mar 02 '23 01:03

Spin City


I also encountered these errors in my environments. I think there's any easier way to change the default code pages.

In windows 10, you could go to "Settings" -> "Region" -> "Administrative" tab -> "Language for non-Unicode programs". Then you could choose the region you want.

In this way, all the codes read from Visual Studio would use the code page whatever you want.

For example, the default setting for me is Chinese (Traditional, Taiwan). The code page is 950. But the codes are using windows-1252, therefore, I change the region to English (United States).

That's it.

Hope the solution could help you.

Thanks.

like image 32
Shu-Ming Liu Avatar answered Mar 02 '23 01:03

Shu-Ming Liu