From 153133aedadde24a5836707caa3ae3632e422ef3 Mon Sep 17 00:00:00 2001 From: Iain Patterson Date: Thu, 9 Jan 2014 09:56:24 +0000 Subject: [PATCH] Force UTF-16 output. If we were compiled as a Unicode application, set stdout and stderr output mode to UTF-16 text. Doing so allows French and Italian accented characters to show up correctly on the console. We currently have no analogous method for fixing the output of NSSM when compiled as an ANSI application. --- nssm.cpp | 9 +++++++++ nssm.h | 2 ++ 2 files changed, 11 insertions(+) diff --git a/nssm.cpp b/nssm.cpp index 3c7545a..8dd264a 100644 --- a/nssm.cpp +++ b/nssm.cpp @@ -85,6 +85,15 @@ int num_cpus() { int _tmain(int argc, TCHAR **argv) { check_console(); +#ifdef UNICODE + /* + Ensure we write in UTF-16 mode, so that non-ASCII characters don't get + mangled. If we were compiled in ANSI mode it won't work. + */ + _setmode(_fileno(stdout), _O_U16TEXT); + _setmode(_fileno(stderr), _O_U16TEXT); +#endif + /* Remember if we are admin */ check_admin(); diff --git a/nssm.h b/nssm.h index 5b89a48..f6c3f35 100644 --- a/nssm.h +++ b/nssm.h @@ -2,6 +2,8 @@ #define NSSM_H #define _WIN32_WINNT 0x0500 +#include +#include #include #include #include -- 2.20.1