[binutils-gdb] PR 33360, Correct strings -Ue output

Alan Modra amodra@sourceware.org
Wed Sep 3 22:58:14 GMT 2025


https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=674628ae3a1daa7fa810f61032ba87e12e576ca6

commit 674628ae3a1daa7fa810f61032ba87e12e576ca6
Author: Andrew C Aitchison <github@aitchison.me.uk>
Date:   Wed Sep 3 15:08:33 2025 +0100

    PR 33360, Correct strings -Ue output
    
    Signed-off-by: Andrew C Aitchison <andrew@aitchison.me.uk>

Diff:
---
 binutils/strings.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/binutils/strings.c b/binutils/strings.c
index f5c022b50a1..38da6381edf 100644
--- a/binutils/strings.c
+++ b/binutils/strings.c
@@ -757,8 +757,8 @@ display_utf8_char (const unsigned char * buffer)
 
 	case 4:
 	  printf ("\\u%02x%02x%02x",
-		  ((buffer[0] & 0x07) << 6) | ((buffer[1] & 0x3c) >> 2),
-		  ((buffer[1] & 0x03) << 6) | ((buffer[2] & 0x3c) >> 2),
+		  ((buffer[0] & 0x07) << 2) | ((buffer[1] & 0x30) >> 4),
+		  ((buffer[1] & 0x0f) << 4) | ((buffer[2] & 0x3c) >> 2),
 		  ((buffer[2] & 0x03) << 6) | ((buffer[3] & 0x3f)));
 	  break;
 	default:


More information about the Binutils-cvs mailing list