Feeling ANSI about Windows console color codes

My first software “product” was a BBS fancy menu generator that utilized ANSI based colors and those funky shaded block characters, to generate a completely new and semi-randomized background pattern on every load. Written in pascal. It ran on a couple BBS’s. Yay.

Today I thought about those ANSI codes and whether they still work in Windows consoles today- found this article on the topic

https://www.jerriepelser.com/blog/using-ansi-color-codes-in-net-console-apps/

Short answer – In modern Windows 10, Yes- but your app need to call some system api’s to enable it, and this is considered fragile. Apparently the safer way to do this, in .Net at least, is via the Console.SetforegroundColor and similar. It looks like Node.js has a built-in layer that decodes the ansi escape codes into these api calls as a sort of proxy, so maybe .Net could use something like this as well? Ok, back to real work.

 

Leave a Reply

Your email address will not be published.