*/
 
 #include "less.h"
+#if MSDOS_COMPILER==WIN32C
+#include <windows.h>
+#endif
 #if HAVE_LOCALE
 #include <locale.h>
 #include <ctype.h>
                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
        /*
        (void) icharset("latin1", 1);
 #endif
 #endif
+#endif
 }
 
 /*
 
 
 #ifdef WIN32
 static char consoleTitle[256];
+static int  savedConsoleCodePage;
 #endif
 
 extern int     less_is_more;
                }
        }
        GetConsoleTitle(consoleTitle, sizeof(consoleTitle)/sizeof(char));
+       savedConsoleCodePage = GetConsoleOutputCP();    
 #endif /* WIN32 */
 
        /*
 #endif
 #ifdef WIN32
        SetConsoleTitle(consoleTitle);
+       SetConsoleOutputCP(savedConsoleCodePage);
 #endif
        close_getchr();
        exit(status);