Why does setlocale give me ? instead of normal letters?

135 Views Asked by At

Programming language: C

IDE: CodeBlocks

Compiler: GNU GCC Compiler

OS: Windows 7

My cmd defaults to code page 852, so I decided to use setlocale(), to set it to code page 437 using

setlocale(LC_ALL, "English_United States.437")

But doing so would make some letters/symbols display as '?' instead. Any way to fix this?

1

There are 1 best solutions below

0
ropeFullOfHope On BEST ANSWER

So I found 2 solutions.

1. You can change the systems default code page under control panel, but it will require to restart the computer and is very impractical, but you can use raster fonts.

2. Using "system("chcp 437");" will set the code page to 437, but you will need to use a font like "Lucida Console" to display characters/symbols as raster fonts for some reason can't print characters/symbols correctly if you change the code page like that.