Created
November 12, 2021 20:40
-
-
Save bredmor/206a36e7ae60bdf0f5a19e94af084641 to your computer and use it in GitHub Desktop.
Revisions
-
bredmor created this gist
Nov 12, 2021 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,25 @@ #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; }