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.
Edited: due the discussion with the OP below
I have only access to windows 10, 1903. Since you have a newer version I think that should apply too.
The cmd.exe has excellent Unicode support from what I know, it does not matter which codepage you are running.  Your premise that there is a codepage conversion is incorrect.  Since the ECHO command is an internal cmd.exe command it supports unicode.
You typing привет in the cmd.exe and using ECHO command means that you are actually using Unicode cmd.exe with Unicode command ECHO which results into printing a Unicode string even with the pagecode 437.  The cmd.exe interpreter is a sub-process of the console as it works from within and it has a Unicode defined.  Thus you are getting correctly привет printed with echo привет.
Your C program forces the console code page on the calling process to translate the console input into corresponding character value.  Which produces your ?????? because code page 437 does not understand Cyrillic's привет.
To quote the SetConsoleCP function MSDN:
Sets the input code page used by the console associated with the calling process. A console uses its input code page to translate keyboard input into the corresponding character value.
For more study of the cmd.exe dicussion you can read excellent answers on SO to these questions (I don't want to duplicate information):
Using UTF-8 Encoding (CHCP 65001) in Command Prompt / Windows Powershell (Windows 10)
How to use unicode characters in Windows command line?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With