Created
November 30, 2017 12:16
-
-
Save Trass3r/08c42909b87be7a6a55e5eb0e8514a56 to your computer and use it in GitHub Desktop.
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 characters
| #ifdef _WIN32 | |
| #include <wincon.h> | |
| #include <cstring> | |
| #endif | |
| static void setupUtf8Console() | |
| { | |
| #ifdef _WIN32 | |
| // set UTF8 code page | |
| SetConsoleOutputCP(65001); | |
| SetConsoleCP(65001); // probably does not work in practice | |
| // set Unicode font | |
| CONSOLE_FONT_INFOEX cfi = {}; | |
| cfi.cbSize = sizeof(cfi); | |
| cfi.dwFontSize.Y = 14; | |
| cfi.FontFamily = FF_DONTCARE; | |
| cfi.FontWeight = FW_NORMAL; | |
| memcpy(cfi.FaceName, L"Lucida Console", sizeof(L"Lucida Console")); | |
| SetCurrentConsoleFontEx(GetStdHandle(STD_OUTPUT_HANDLE), FALSE, &cfi); | |
| #endif | |
| } | |
| int main(int argc, const char** argv) | |
| { | |
| setupUtf8Console(); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment