Created
September 15, 2013 15:10
-
-
Save thekid/6571614 to your computer and use it in GitHub Desktop.
Output UTF-8 to Windows Shell
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
| #include <wchar.h> | |
| #include <stdlib.h> | |
| #include <stdio.h> | |
| #include <fcntl.h> | |
| #include <io.h> | |
| int wmain(int argc, wchar_t** argv) { | |
| int i; | |
| _setmode(_fileno(stdout), _O_U8TEXT); | |
| fwprintf(stdout, L"args [%d]{", argc); | |
| for (i = 0; i < argc; i++) { | |
| fwprintf(stdout, L"(%d)'%ls', ", wcslen(argv[i]), argv[i]); | |
| } | |
| fwprintf(stdout, L"}\n"); | |
| return 0; | |
| } |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Cygwin mintty w/ encoding = utf-8:
Windows "cmd.exe" regardless of current codepage(!)