From 9eb997fc0b5172d00507e7dcfeb2c68783d40190 Mon Sep 17 00:00:00 2001 From: zhuangzhuang Date: Mon, 8 Jul 2019 14:33:53 +0800 Subject: [PATCH] fix windows stdout messy code (#2546) * fix windows stdout messy code * fix type name error * remoe unnecessary codepoint check. --- src/api/tesseractmain.cpp | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/api/tesseractmain.cpp b/src/api/tesseractmain.cpp index f2d807f6..b77e16e6 100644 --- a/src/api/tesseractmain.cpp +++ b/src/api/tesseractmain.cpp @@ -69,6 +69,22 @@ static void Win32WarningHandler(const char* module, const char* fmt, } #endif /* HAVE_TIFFIO_H */ + +class AutoWin32ConsoleOutputCP { + public: + explicit AutoWin32ConsoleOutputCP(UINT codeCP) { + oldCP_ = GetConsoleOutputCP(); + SetConsoleOutputCP(codeCP); + } + ~AutoWin32ConsoleOutputCP() { + SetConsoleOutputCP(oldCP_); + } + private: + UINT oldCP_; +}; + +static AutoWin32ConsoleOutputCP autoWin32ConsoleOutputCP(CP_UTF8); + #endif // _WIN32 static void PrintVersionInfo() {