Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix enable_ansi_support() for redirected STDOUT
.# Discussion Even though it is used in sample methods included in the Microsoft documentation, the `GetStdHandle(winapi::um::winbase::STD_OUTPUT_HANDLE)` method of retrieving the console handle is a poor choice. It will fail if STDOUT is redirected, even when a viable console is available. This can lead to incorrectly colored STDERR when STDOUT is redirected. Using `CreateFile2("CONOUT$", ...)` instead succeeds even when STDOUT and/or STDERR are redirected. [1]: https://docs.microsoft.com/en-us/windows/console/console-virtual-terminal-sequences#samples @@ https://archive.is/PHjnN#70.5% [2]: https://docs.microsoft.com/en-us/windows/desktop/api/fileapi/nf-fileapi-createfile2#consoles @@ https://archive.is/7BWhB#71.8%
- Loading branch information