My console window have a code page of 437
, and I have echoed Russian letters in the console window:
echo привет
And I got the correct Russian output, which is:
привет
But why am I getting the correct Russian output, shouldn't I get 6 question marks as output ("??????")? The reason why I think I should get "??????" as output is because before the string "echo привет" is sent to the stdin buffer, it should be converted into the 437
code page (which will produce "??????" since those Russian letters don't exist in the 437
code page) and then the converted string would be sent to the stdin buffer, and then the "??????" string would be retrieved from the stdin buffer by cmd.exe and cmd.exe would print it to the console window.
I know that this is what should happen because I created a C program that sets the code page of the console window it is associated with to 437
, and then I would send the program the "привет" Russian letters and then the program will print it to the console window (what will be printed is the "??????" string), this is the code for my program:
#include <Windows.h>
#include <stdio.h>
int main()
{
SetConsoleOutputCP(437);
SetConsoleCP(437);
char str[1212];
gets(str);
printf(str);
return 0;
}
I am using the classic console window (and not PowerShell), and I am using Windows 10.