Преглед изворни кода

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.
Iain Patterson пре 10 година
родитељ
комит
153133aeda
2 измењених фајлова са 11 додато и 0 уклоњено
  1. 9 0
      nssm.cpp
  2. 2 0
      nssm.h

+ 9 - 0
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();
 

+ 2 - 0
nssm.h

@@ -2,6 +2,8 @@
 #define NSSM_H
 
 #define _WIN32_WINNT 0x0500
+#include <fcntl.h>
+#include <io.h>
 #include <shlwapi.h>
 #include <stdarg.h>
 #include <stdio.h>