Partition names in the GUID partition table are internally encoded as UTF-16LE while the I/O charset of the commands is UTF-8. When displaying partition names, conversion to UTF-8 is broken for non-ASCII Unicode code points. To reproduce the problem, create a partition with e.g. "😬" as its name: $ truncate -s 16M /tmp/test.img $ sgdisk -o -n 1:0:0 -c "1:😬" -p /tmp/test.img Disk /tmp/test.img: 32768 sectors, 16.0 MiB Sector size (logical): 512 bytes Disk identifier (GUID): 79DACFC1-8C4F-4191-A8C3-94CC8E31D608 Partition table holds up to 128 entries Main partition table begins at sector 2 and ends at sector 33 First usable sector is 34, last usable sector is 32734 Partitions will be aligned on 2048-sector boundaries Total free space is 2014 sectors (1007.0 KiB) Number Start (sector) End (sector) Size Code Name 1 2048 32734 15.0 MiB 8300 ���� Warning: The kernel is still using the old partition table. The new table will be used at the next reboot or after you run partprobe(8) or kpartx(8) The operation has completed successfully. Note the name "����" (bytes 0xf0 0xff 0x98 0xac) in the summary output. hexdump shows that the name is correct on disk, namely UTF-16 surrogates 0xd83d and 0xde2c at offset 0x38: $ dd if=/tmp/test.img bs=1 skip=1024 count=128 status=none | hexdump -C 00000000 af 3d c6 0f 83 84 72 47 8e 79 3d 69 d8 47 7d e4 |.=....rG.y=i.G}.| 00000010 2f e2 a1 a9 64 f9 81 49 a9 ad c4 47 12 9b c5 64 |/...d..I...G...d| 00000020 00 08 00 00 00 00 00 00 de 7f 00 00 00 00 00 00 |................| 00000030 00 00 00 00 00 00 00 00 3d d8 2c de 00 00 00 00 |........=.,.....| 00000040 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| * 00000080
Created attachment 887547 [details, diff] gptpart.cc: Fix Unicode to UTF-8 conversion in GetDescription Attached patch fixes the problem for me.
I've also reported the problem upstream.
Patch has been accepted upstream: https://sourceforge.net/p/gptfdisk/code/ci/0e13e907ced9981024d0bdec7e2dc1b2081c9cbe/
The bug has been closed via the following commit(s): https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=1186f2046dd460413a7b2cf97a67fc137fb0ef85 commit 1186f2046dd460413a7b2cf97a67fc137fb0ef85 Author: Marek Szuba <marecki@gentoo.org> AuthorDate: 2024-03-29 14:23:54 +0000 Commit: Marek Szuba <marecki@gentoo.org> CommitDate: 2024-03-29 14:24:55 +0000 sys-apps/gptfdisk: add 1.0.10 Closes: https://bugs.gentoo.org/926949 Signed-off-by: Marek Szuba <marecki@gentoo.org> sys-apps/gptfdisk/Manifest | 1 + sys-apps/gptfdisk/gptfdisk-1.0.10.ebuild | 60 ++++++++++++++++++++++++++++++++ 2 files changed, 61 insertions(+)
Actually this isn't fixed in 1.0.10. However, it's a minor problem, so no need to add a local patch for it.
The bug has been referenced in the following commit(s): https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=cb6fca52f4cbb863b5cb15fd431298374e23633d commit cb6fca52f4cbb863b5cb15fd431298374e23633d Author: Marek Szuba <marecki@gentoo.org> AuthorDate: 2024-04-07 14:07:07 +0000 Commit: Marek Szuba <marecki@gentoo.org> CommitDate: 2024-04-07 14:07:07 +0000 sys-apps/gptfdisk: fix UTF-16LE to UTF-8 conversion for partition names Given the timing of the release of 1.0.10 I assumed it would have already been incorporated upstream, turns out I was wrong though. Thanks for the heads-up, ulm! Bug: https://bugs.gentoo.org/926949 Signed-off-by: Marek Szuba <marecki@gentoo.org> .../gptfdisk-1.0.10_utf16-to-utf8-conversion.patch | 19 +++++++++++++++++++ ...tfdisk-1.0.10.ebuild => gptfdisk-1.0.10-r1.ebuild} | 1 + 2 files changed, 20 insertions(+)