Force UTF-16 output.
[nssm.git] / nssm.cpp
index 3c7545a..8dd264a 100644 (file)
--- a/nssm.cpp
+++ b/nssm.cpp
@@ -85,6 +85,15 @@ int num_cpus() {
 int _tmain(int argc, TCHAR **argv) {\r
   check_console();\r
 \r
+#ifdef UNICODE\r
+  /*\r
+    Ensure we write in UTF-16 mode, so that non-ASCII characters don't get\r
+    mangled.  If we were compiled in ANSI mode it won't work.\r
+   */\r
+  _setmode(_fileno(stdout), _O_U16TEXT);\r
+  _setmode(_fileno(stderr), _O_U16TEXT);\r
+#endif\r
+\r
   /* Remember if we are admin */\r
   check_admin();\r
 \r