Created
November 12, 2021 20:40
-
-
Save bredmor/206a36e7ae60bdf0f5a19e94af084641 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <cstdio> | |
#include <windows.h> | |
#define INPUT_MAX 255 | |
void main() | |
{ | |
wchar_t wstr[INPUT_MAX]; | |
char mb_str[INPUT_MAX * 3 + 1]; | |
unsigned long readln; | |
SetConsoleOutputCP(CP_UTF8); | |
SetConsoleCP(CP_UTF8); | |
void *console = GetStdHandle(STD_INPUT_HANDLE); | |
ReadConsole(console, wstr, INPUT_MAX, &readln, NULL); | |
int size = WideCharToMultiByte(CP_UTF8, 0, wstr, readln, mb_str, sizeof(mb_str), NULL, NULL); | |
mb_str[size] = 0; | |
printf("echo: %s\n", mb_str); | |
return; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment