P
P
PSiOO22021-10-22 00:41:48
C++ / C#
PSiOO2, 2021-10-22 00:41:48

Why does the Cyrillic cout output in C++ produce characters of obscure origin?

After transferring the file via the Internet, it stopped displaying the Cyrillic alphabet correctly, immediately under suspicion was the setting of one of the devices. At the same time, the Cyrillic alphabet in the reminder about the automatic closing of the window looks normal.
6171de0cecb72849310834.png
I tried the solution with the inclusion

#include <windows.h>
#include <clocale>

int main(int argc, char** argv) 
{
    setlocale(LC_ALL, "Russian");
    SetConsoleOutputCP(1251);
    SetConsoleCP(1251);

This led to the replacement of extraterrestrial symbols with familiar ones.
6171de43db7ab240065552.png

Answer the question

In order to leave comments, you need to log in

1 answer(s)
W
wisgest, 2021-10-22
@wisgest

SetConsoleOutputCP(1251);
SetConsoleCP(1251);

As I understand it, there should be an encoding in which your source code is saved.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question