[PATCH 2/3] Display 4-byte UTF-8 as \\Uxxxxxxxx
Andrew C Aitchison
werdna@aitchison.me.uk
Sat Sep 13 15:12:28 GMT 2025
---
binutils/doc/binutils.texi | 8 ++++----
binutils/nm.c | 2 +-
binutils/objdump.c | 2 +-
binutils/readelf.c | 4 ++--
binutils/strings.c | 4 ++--
5 files changed, 10 insertions(+), 10 deletions(-)
diff --git a/binutils/doc/binutils.texi b/binutils/doc/binutils.texi
index 89425b8a15b..5bfc0c6acb9 100644
--- a/binutils/doc/binutils.texi
+++ b/binutils/doc/binutils.texi
@@ -1213,7 +1213,7 @@ in the current locale, which may or may not support them. The options
hex byte sequences enclosed by either angle brackets or curly braces.
The @option{--unicode=escape} option displays them as escape sequences
-(@var{\uxxxx}) and the @option{--unicode=highlight} option displays
+(@var{\uxxxx} and @var{\Uxxxxxxxx}) and the @option{--unicode=highlight} option displays
them as escape sequences highlighted in red (if supported by the
output device). The colouring is intended to draw attention to the
presence of unicode sequences where they might not be expected.
@@ -3079,7 +3079,7 @@ in the current locale, which may or may not support them. The options
hex byte sequences enclosed by either angle brackets or curly braces.
The @option{--unicode=escape} option displays them as escape sequences
-(@var{\uxxxx}) and the @option{--unicode=highlight} option displays
+(@var{\uxxxx} and @var{\Uxxxxxxxx) and the @option{--unicode=highlight} option displays
them as escape sequences highlighted in red (if supported by the
output device). The colouring is intended to draw attention to the
presence of unicode sequences where they might not be expected.
@@ -3492,7 +3492,7 @@ The @option{--unicode=locale} option displays them in the current
locale, which may or may not support UTF-8 encoding. The
@option{--unicode=hex} option displays them as hex byte sequences
enclosed between @var{<>} characters. The @option{--unicode=escape}
-option displays them as escape sequences (@var{\uxxxx}) and the
+option displays them as escape sequences (@var{\uxxxx} and @var{\Uxxxxxxxx) and the
@option{--unicode=highlight} option displays them as escape sequences
highlighted in red (if supported by the output device). The colouring
is intended to draw attention to the presence of unicode sequences
@@ -5231,7 +5231,7 @@ they are displayed as a sequence of hex bytes, encloses in curly
parethesis characters.
Using the @option{--unicode=escape} option will display the characters
-as as unicode escape sequences (@var{\uxxxx}). Using the
+as as unicode escape sequences (@var{\uxxxx} and @var{\Uxxxxxxxx). Using the
@option{--unicode=hex} will display the characters as hex byte
sequences enclosed between angle brackets.
diff --git a/binutils/nm.c b/binutils/nm.c
index 95d85a069c0..ed7edecffe0 100644
--- a/binutils/nm.c
+++ b/binutils/nm.c
@@ -563,7 +563,7 @@ display_utf8 (const unsigned char * in, char * out, unsigned int * consumed)
break;
case 4:
- out += sprintf (out, "\\u%06x",
+ out += sprintf (out, "\\U%08x",
((in[0] & 0x07) << 18)
| ((in[1] & 0x3f) << 12)
| ((in[2] & 0x3f) << 6)
diff --git a/binutils/objdump.c b/binutils/objdump.c
index 490b909cd89..b6d8b3f22da 100644
--- a/binutils/objdump.c
+++ b/binutils/objdump.c
@@ -656,7 +656,7 @@ display_utf8 (const unsigned char * in, char * out, unsigned int * consumed)
break;
case 4:
- out += sprintf (out, "\\u%06x",
+ out += sprintf (out, "\\U%08x",
((in[0] & 0x07) << 18)
| ((in[1] & 0x3f) << 12)
| ((in[2] & 0x3f) << 6)
diff --git a/binutils/readelf.c b/binutils/readelf.c
index 469b9baf928..da9824cee28 100644
--- a/binutils/readelf.c
+++ b/binutils/readelf.c
@@ -843,9 +843,9 @@ print_symbol_name (signed int width, const char * symbol)
((bytes[0] & 0x0f) << 12) | ((bytes[1] & 0x3f) << 6) | ((bytes[2] & 0x3f)) );
break;
case 4:
- if (width_remaining < 8)
+ if (width_remaining < 10)
break;
- printf ( "\\u%06x",
+ printf ( "\\U%08x",
((bytes[0] & 0x07) << 18)
| ((bytes[1] & 0x3f) << 12)
| ((bytes[2] & 0x3f) << 6)
diff --git a/binutils/strings.c b/binutils/strings.c
index a8f489b9bf0..f71b9e1bb25 100644
--- a/binutils/strings.c
+++ b/binutils/strings.c
@@ -754,8 +754,8 @@ display_utf8_char (const unsigned char * buffer)
break;
case 4:
- printf("\\u%06x",
- ((buffer[0] & 0x07) << 18)
+ printf("\\U%08x",
+ ((buffer[0] & 0x07) << 18)
| ((buffer[1] & 0x3f) << 12)
| ((buffer[2] & 0x3f) << 6)
| ((buffer[3] & 0x3f)) );
--
2.48.1
More information about the Binutils
mailing list