Color ANSI codes don't work anymore

Lapo Falcone 21 Reputation points
2020-05-28T11:19:37.943+00:00

I wrote a program in C++ about 2/3 weeks ago. It has a line where it should print some text with a specific color. To do so I decided to use ANSI escape color codes. I know there are other ways, but this one seems the most straight forward.

So for example I used: std::cout << "\x1B[31mTEST RED\033[0m\n"; to print red text.

I compiled and linked the code using MSVC, it produced an .exe file, I ran it and all worked fine.

Yesterday I ran that same .exe file again, but this time it printed the string "←[31mTEST RED←[0m", white.

I don't know how is this possible, I haven't touched the .exe file in any way, but 2 weeks ago it worked, now it doesn't!

I contacted MS support, and they tried to update my Windows version to the newest one, but it didn't solved the issue, so they told me to ask here.

If you need more information I'll give it to you as soon as possible. Thanks!

Not Monitored
Not Monitored
Tag not monitored by Microsoft.
38,836 questions
0 comments No comments
{count} votes

Accepted answer
  1. Leon Laude 85,781 Reputation points
    2020-05-28T11:28:09.687+00:00

    Hi,

    Q&A currently supports the products listed over here https://learn.microsoft.com/en-us/answers/products (more to be added later on).

    You can reach the experts in the dedicated Microsoft Visual Studio forum over here:
    https://social.msdn.microsoft.com/Forums/vstudio/en-US/home?category=visualstudio

    (Please don't forget to accept helpful replies as answer)

    Best regards,
    Leon


0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.