mlbv-archived icon indicating copy to clipboard operation
mlbv-archived copied to clipboard

ANSI escape codes not supported on Windows CMD

Open davefrancis opened this issue 5 years ago • 3 comments

ANSI colour sequences are not supported on Windows and as a result the output of mlbv looks like this:

2018-10-02 Tue Series ?[90m│?[0m Score ?[90m│?[0m State ?[90m│?[0m Feeds ?[90m─────────────────────────────────────────────────────────┼───────┼───────────┼────────────────?[0m 17:00: Colorado (COL) at Chi Cubs (CHC) 1/1 ?[0m ?[90m│?[0m ?[0m ?[90m│?[0m ?[0m ?[90m│?[0m ?[0m

It would be nice to have an option to use ANSI colours in console output.

davefrancis avatar Oct 02 '18 15:10 davefrancis

Which terminal program are you using in Windows? is it cmd.exe?

It looks like some support for ansi colors can be enabled as of Windows 10. Some discussions on this:

  • https://superuser.com/questions/413073/windows-console-with-ansi-colors-handling
  • https://stackoverflow.com/questions/16755142/how-to-make-win32-console-recognize-ansi-vt100-escape-sequences

Another option might be to use the ConEmu terminal emulator: https://conemu.github.io/

I don't, uh, actually have a windows installation that I can test this with. I think what I would do is add a way to turn all ansi-control characters off in the output. You won't see colours but at least you'd see non-garbled text.

kmac avatar Oct 02 '18 19:10 kmac

I've tried in cmd.exe and powershell with the same results. I have read that ConEmu supports ANSI colours, so definitely an option. I forked your repo and have been experimenting. I found this snippit https://gist.github.com/RDCH106/6562cc7136b30a5c59628501d87906f7 resolves the issue on Windows 10. For versions of windows before 10.0.14393 it may be best to turn colours off altogether. I'm happy to help with any testing if you'd like. Cheers.

davefrancis avatar Oct 02 '18 20:10 davefrancis

IMO, the easiest way to accomplish colors is to add a DWORD (32-bit value) registry key to HKCU\Console called VirtualTerminalLevel set to 0x1.

SlimJimPoisson avatar Aug 01 '20 14:08 SlimJimPoisson