[PATCH 1/2] Show 4 byte UTF-8 as \Uxxxxxxxx Simplify this by using a single uint32 rather than four bytes.
Michael Matz
matz@suse.de
Tue Sep 9 13:54:34 GMT 2025
Hello,
On Tue, 9 Sep 2025, Andrew C Aitchison wrote:
> diff --git a/binutils/readelf.c b/binutils/readelf.c
> index 8162cbb7003..2ed40f073fb 100644
> --- a/binutils/readelf.c
> +++ b/binutils/readelf.c
> @@ -847,11 +847,11 @@ print_symbol_name (signed int width, const char * symbol)
> case 4:
> if (width_remaining < 8)
> break;
This still checks for 8 characters fitting ...
> - printf ("\\u%02x%02x%02x",
> - ((bytes[0] & 0x07) << 2) | ((bytes[1] & 0x30) >> 4),
> - ((bytes[1] & 0x0f) << 4) | ((bytes[2] & 0x3c) >> 2),
> - ((bytes[2] & 0x03) << 6) | (bytes[3] & 0x3f));
> -
> + printf ("\\U%08x",
> + ((bytes[0] & 0x07) << 18) |
> + ((bytes[1] & 0x3f) << 12) |
> + ((bytes[2] & 0x3f) << 6) |
> + ((bytes[3] & 0x3f)) );
... while you now emit 10.
Ciao,
Michael.
More information about the Binutils
mailing list