Skip to content

Instantly share code, notes, and snippets.

@elieux
Last active April 27, 2017 22:34
Show Gist options
  • Save elieux/39922160f46c6b634654917b2eb598e1 to your computer and use it in GitHub Desktop.
Save elieux/39922160f46c6b634654917b2eb598e1 to your computer and use it in GitHub Desktop.
Print wide characters
// > gcc -Wall -Wextra -municode -std=c11 -o xecho.exe echo.c
#define WIN32_LEAN_AND_MEAN 1
#define __USE_MINGW_ANSI_STDIO 1
#include <stdio.h>
#include <wchar.h>
#include <io.h>
#include <fcntl.h>
int wmain(int argc, wchar_t *argv[]) {
_setmode(_fileno(stdout), _O_U16TEXT);
for (int i = 1; i < argc; ++i) {
if (i > 1) {
wprintf(L" ");
}
wprintf(L"%ls", argv[i]);
}
wprintf(L"\n");
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment