LinuxAcademy-DL icon indicating copy to clipboard operation
LinuxAcademy-DL copied to clipboard

ANSI Escape characters not coloring on CMD terminal on Windows 10

Open niranjan23d opened this issue 5 years ago • 1 comments

Although Windows 10 TH2 (v1511) added support for ANSI escape sequences, colors still do not show up on the terminal; the reason is that the feature must be enabled/utilized by the program accessing the terminal.

The check mark sign also appears as a question mark within a box.

Here is my solution to the problem:

  1. For the check mark, I modified the string and entered the sqrt symbol - u"\u221A" OR by holding ALT + 251 (numpad).
  2. For colored output, I just used this snippet from Stackoverflow. Rahul, you could make it so that this works if driver.py detects if it is a Windows system only.
import ctypes

kernel32 = ctypes.windll.kernel32
kernel32.SetConsoleMode(kernel32.GetStdHandle(-11), 7)

Windows working proof: image

niranjan23d avatar Sep 08 '20 23:09 niranjan23d

Okay, noted!

RahulShaw avatar Jan 11 '21 16:01 RahulShaw