Answer the question
In order to leave comments, you need to log in
Why do question marks appear in the console instead of the Russian language?
Hello, why are question marks displayed when outputting Russian text to the console??
setlocale(LC_ALL, "rus") registered, but still instead of Russian characters, question marks.
Could the problem be that my windows 10 is in English?
#include <iostream>
using namespace std;
int main()
{
setlocale(LC_ALL, "rus");
cout << "Отчего работать дяди\n" << "Стали лучше по утру ?\n" << "Просто им администратор\n" << "Просто им администратор\n" << "Отключил vkontakte.ru!\n";
system("pause");
return 0;
}
Answer the question
In order to leave comments, you need to log in
This is pretty much the first question C++ juniors get when they try to run their first console program under Windows.
There were already a whole bunch of answers to it.
The bottom line is that in the Windows console there can be 2 Russian encodings (cp866 and cp1251) (I'm not sure, but maybe the Windows console has already learned to work normally with UTF8, if it has learned, then consider that another encoding has been added). And the default is cp866. The console encoding can be changed from the console itself or programmatically.
When outputting text to the console, no encoding conversions occur. In what encoding you have written the source codes - that one is displayed. And if the console encoding and the source encoding do not match, then the text will not be readable.
The most optimal and most difficult option is to find out the console encoding in the program and convert the text to this encoding before outputting it. Perform the same reverse operation on input. In this case, it is best to write the program source in UTF8 and use wchar_t.
The simplest, moronic and not always working (will not work if the console encoding is changed) is to write the source code in cp866.
A little more complicated, but not correct - to change the console encoding from the program to the one in which the sources are written.
The most reliable option - do not use Russian in console programs - only English. I doubt that you will ever write professional console utilities that can adapt to different encodings, so it may not make sense to delve into this topic. GUI applications do not have this problem.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question