On 07/09/2016 10:12 PM, Dāvis Mosāns wrote: > int main(int ac, char const* const* av) > { > +#if defined(_WIN32) > + // Replace streambuf so we can output Unicode to console > + cmsys::ConsoleBuf *cbufio = CM_NULLPTR; > + cmsys::ConsoleBuf *cbuferr = CM_NULLPTR; > + std::streambuf *coutbuf = std::cout.rdbuf(); > + std::streambuf *cerrbuf = std::cerr.rdbuf(); > + try { > + cbufio = new cmsys::ConsoleBuf(); > + coutbuf = std::cout.rdbuf(cbufio); > + cbuferr = new cmsys::ConsoleBuf(true); > + cerrbuf = std::cerr.rdbuf(cbuferr); > + } catch (const std::runtime_error& ex) { > + std::cerr << "Failed to create ConsoleBuf!" << std::endl > + << ex.what() << std::endl; > + }; > +#endif ... > +#if defined(_WIN32) > + if (cbufio) { > + delete cbufio; > + std::cout.rdbuf(coutbuf); > + } > + if (cbuferr) { > + delete cbuferr; > + std::cerr.rdbuf(cerrbuf); > + } > +#endif
Please add to KWSys ConsoleBuf a RAII-style helper to perform the above steps. Its constructor can take either std::cout or std:cerr by reference. Also, please add a test case for this to KWSys itself. The test should at least be able to compile and run. Verification that output looks right may need to be a manual step though. Thanks, -Brad -- Powered by www.kitware.com Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ Kitware offers various services to support the CMake community. For more information on each offering, please visit: CMake Support: http://cmake.org/cmake/help/support.html CMake Consulting: http://cmake.org/cmake/help/consulting.html CMake Training Courses: http://cmake.org/cmake/help/training.html Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html Follow this link to subscribe/unsubscribe: http://public.kitware.com/mailman/listinfo/cmake-developers