C++ Logo

std-proposals

Advanced search

Re: [std-proposals] Colored printing for std::print and std::println

From: Jan Schultke <janschultke_at_[hidden]>
Date: Mon, 20 May 2024 08:09:54 +0200
Colored printing is generally useful, but I think it's better done
using third-party libraries.

The link you've posted relies on ANSI escape sequences, and not every
terminal emulator supports them. Older versions of cmd.exe didn't
allow for this, for example. I'm also not sure how consistent various
terminal emulators are in implementing the various ANSI escape codes.
ANSI sequences also aren't something nice that can be abstracted from
easily, like RGB colors. They are made of various palettes and it all
feels a bit arbitrary.

All you need to get some basic ANSI features is to include some header
with a bunch of "inline constexpr string_view" constants for various
ANSI codes, so it's also not like this *needs* to be in the standard
library for a viable implementation. It's quite trivial.

Received on 2024-05-20 06:10:08