]> www.wagner.pp.ru Git - oss/less.git/blobdiff - charset.c
Force output codepage to 65001 and restore before quit
[oss/less.git] / charset.c
index 4c62664e73d1008a48dc8bb564314c3c4c56f272..69b035f1d4a736f667470c43eef4dee57e2434e9 100644 (file)
--- a/charset.c
+++ b/charset.c
@@ -14,6 +14,9 @@
  */
 
 #include "less.h"
+#if MSDOS_COMPILER==WIN32C
+#include <windows.h>
+#endif
 #if HAVE_LOCALE
 #include <locale.h>
 #include <ctype.h>
@@ -319,7 +322,15 @@ set_charset()
                ichardef(s);
                return;
        }
-
+#ifdef WIN32
+       SetConsoleOutputCP(65001);
+    _setmode(_fileno(stdout),_O_U8TEXT);
+    _setmode(_fileno(stderr),_O_U8TEXT);
+       if (isatty(fileno(stdin))) 
+               _setmode(_fileno(stdin),_O_U8TEXT);
+       icharset("UTF-8",0);
+       
+#else 
 #if HAVE_LOCALE
 #ifdef CODESET
        /*
@@ -364,6 +375,7 @@ set_charset()
        (void) icharset("latin1", 1);
 #endif
 #endif
+#endif
 }
 
 /*