From 335a29cb07a8d014a9ed4d4dbf25e49da3a78b33 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?D=C4=81vis=20Mos=C4=81ns?= Date: Sat, 1 Oct 2016 03:11:35 +0300 Subject: Enable Unicode output to Windows consoles Use KWSys ConsoleBuf to replace the `streambuf` on `std::cout` and `std::cerr` so that process output can be encoded correctly for display in a Windows console. --- Source/cmakemain.cxx | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'Source/cmakemain.cxx') diff --git a/Source/cmakemain.cxx b/Source/cmakemain.cxx index d1159c31e4..44af96607e 100644 --- a/Source/cmakemain.cxx +++ b/Source/cmakemain.cxx @@ -18,6 +18,9 @@ #include #include +#if defined(_WIN32) && defined(CMAKE_BUILD_WITH_CMAKE) +#include +#endif #include #include #include @@ -153,6 +156,11 @@ static void cmakemainProgressCallback(const char* m, float prog, int main(int ac, char const* const* av) { +#if defined(_WIN32) && defined(CMAKE_BUILD_WITH_CMAKE) + // Replace streambuf so we can output Unicode to console + cmsys::ConsoleBuf::Manager consoleOut(std::cout); + cmsys::ConsoleBuf::Manager consoleErr(std::cerr, true); +#endif cmsys::Encoding::CommandLineArguments args = cmsys::Encoding::CommandLineArguments::Main(ac, av); ac = args.argc(); -- cgit v1.2.1