I have tried Ansicon and I still cannot get ansi escape sequences to become recognized and interpreted in my CMD.EXE command prompt on Windows 7 64 bit. Has anyone been able to work this correctly and get a colorized console with this OS?
The ANSI ASCII standard represents the escape ESC character by the decimal number 27 (33 in octal, 1B in hexadecimal). This is one of the control characters (0-31 and 127), not one of the printable characters (32-126).
To use ANSI colours in the Windows terminal requires setting VirtualTerminalLevel. VirtualTerminalLevel = 1 is now set by default for the terminal and in ConPTY. Alternatively it can be enabled by calling the SetConsoleMode API with the ENABLE_VIRTUAL_TERMINAL_PROCESSING flag.
The advantage of using ANSI escape codes is that, today, these are available on most operating systems, including Windows, and you don't need to install third party libraries. These are well suited for simple command line applications. If you need to do complex text graphics check the ncurses library.
I ran into the same problem today, and found a workaround.
The commandline utility Windows ANSI Color detects ANSI color codes and sets the corresponding console color.
Example:
myapp.bat | wac
where wac is the Windows ANSI color utility
Ansicon use dll injection in order to enable ansi color in cmd.exe, which is disabled with the standard user privileges.
Try launching ansicon with "run as administrator" (right click)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With