Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Tom de Vries <tdevries@suse.de>
To: gdb-patches@sourceware.org
Subject: [PATCH] [gdb] Rewrite error and warning emojis
Date: Wed, 12 Aug 2026 15:55:54 +0200	[thread overview]
Message-ID: <20260812135554.2356569-1-tdevries@suse.de> (raw)

While working on PR34501 I realized that these two strings actually contain
two unicode characters:
...
static std::string warning_prefix = "⚠️ ";
static std::string error_prefix = "❌️ ";
...

Both the Warning Sign [1] and the Cross Mark [2] are followed by Variation
Selector-16 (VS16) [3].

To make this obvious, I decided to rewrite in a style that makes it explicit
both which unicode characters are used, and how they are encoded:
...
static std::string warning_prefix = u8"\u26A0\uFE0F ";
...

In the process I found out that the Cross Mark doesn't need VS16, because its
default presentation is already "Emoji" rather than "Text", so that one simply
becomes:
...
static std::string error_prefix = u8"\u274C ";
...

AFAICT, this property (default presentation == "Emoji") can be verified by
finding Cross Mark here [4] and checking that property Emoji_Presentation
applies.

Tested on x86_64-linux.

[1] https://www.compart.com/en/unicode/U+26A0
[2] https://www.compart.com/en/unicode/U+274C
[3] https://www.compart.com/en/unicode/U+FE0F
[4] https://www.unicode.org/Public/17.0.0/ucd/emoji/emoji-data.txt
---
 gdb/cli/cli-style.c              | 15 +++++++++++----
 gdb/testsuite/gdb.base/style.exp |  2 +-
 2 files changed, 12 insertions(+), 5 deletions(-)

diff --git a/gdb/cli/cli-style.c b/gdb/cli/cli-style.c
index 03a887232c7..5c175ee29ea 100644
--- a/gdb/cli/cli-style.c
+++ b/gdb/cli/cli-style.c
@@ -449,8 +449,12 @@ no_emojis ()
   emoji_styling = AUTO_BOOLEAN_FALSE;
 }
 
-/* Emoji warning prefix.  */
-static std::string warning_prefix = "⚠️ ";
+/* Emoji warning prefix:
+   - u26A0: Warning Sign: ⚠
+   - uFE0F: Variation Selector-16 (VS16)
+   The VS16 forces "Emoji" presentation.  It is needed because the default
+   presentation for Warning Sign is "Text".  Together, we get: ⚠️ .  */
+static std::string warning_prefix = u8"\u26A0\uFE0F ";
 
 /* Implement 'show style warning-prefix'.  */
 
@@ -471,8 +475,11 @@ print_warning_prefix (ui_file *file)
     gdb_puts (warning_prefix.c_str (), file);
 }
 
-/* Emoji error prefix.  */
-static std::string error_prefix = "❌️ ";
+/* Emoji error prefix:
+   - u274C: Cross Mark: ❌
+   No VS16 is needed because the default presentation for Cross Mark is
+   "Emoji".  */
+static std::string error_prefix = u8"\u274C ";
 
 /* Implement 'show style error-prefix'.  */
 
diff --git a/gdb/testsuite/gdb.base/style.exp b/gdb/testsuite/gdb.base/style.exp
index 8a49d1c5973..8d576ff00f1 100644
--- a/gdb/testsuite/gdb.base/style.exp
+++ b/gdb/testsuite/gdb.base/style.exp
@@ -335,7 +335,7 @@ proc run_style_tests { } {
 	gdb_test_no_output "set host-charset UTF-8"
 	# Chosen since it will print an error.
 	gdb_test "maint translate-address" \
-	    "❌️ requires argument.*" \
+	    "❌ requires argument.*" \
 	    "emoji output"
 
 	gdb_test_no_output "set style error-prefix abcd:" \

base-commit: 17afc47d8bc304f527eb58ea8086a39fdc0cbd19
-- 
2.51.0


             reply	other threads:[~2026-08-12 13:56 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-12 13:55 Tom de Vries [this message]
2026-08-12 20:03 ` Tom Tromey

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260812135554.2356569-1-tdevries@suse.de \
    --to=tdevries@suse.de \
    --cc=gdb-patches@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox