[Bug 281796] /bin/ls doesn't print UTF-8 emojis properly in some cases, but /bin/du does

From: <bugzilla-noreply_at_freebsd.org>
Date: Tue, 01 Oct 2024 14:03:49 UTC
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=281796

            Bug ID: 281796
           Summary: /bin/ls doesn't print UTF-8 emojis properly in some
                    cases, but /bin/du does
           Product: Base System
           Version: 14.1-RELEASE
          Hardware: Any
                OS: Any
            Status: New
          Severity: Affects Only Me
          Priority: ---
         Component: bin
          Assignee: bugs@FreeBSD.org
          Reporter: henrichhartzer@tuta.io

I had some filenames with emojis on my filesystem and noticed an interesting
behavior.

I noticed that /bin/du will print the filename and size with the emoji, but
/bin/ls prints question marks.

zsh$ du this-has-an-apple-emoji-$'\360'$'\237'$'\215'$'\216'
0       this-has-an-apple-emoji-🍎
zsh$ ls this-has-an-apple-emoji-$'\360'$'\237'$'\215'$'\216'
this-has-an-apple-emoji-????
zsh$ du this-has-an-apple-emoji-$'\360'$'\237'$'\215'$'\216' | hexdump -C
00000000  30 09 74 68 69 73 2d 68  61 73 2d 61 6e 2d 61 70  |0.this-has-an-ap|
00000010  70 6c 65 2d 65 6d 6f 6a  69 2d f0 9f 8d 8e 0a     |ple-emoji-.....|
0000001f
zsh$ ls this-has-an-apple-emoji-$'\360'$'\237'$'\215'$'\216' | hexdump -C
00000000  74 68 69 73 2d 68 61 73  2d 61 6e 2d 61 70 70 6c  |this-has-an-appl|
00000010  65 2d 65 6d 6f 6a 69 2d  f0 9f 8d 8e 0a           |e-emoji-.....|
0000001d

Although, I think it's more complicated than that. This is my behavior with
x11/foot, but not with x11/sterm.

This may not be a /bin/ls bug, but seems to be a discrepancy between /bin/ls
and /bin/du.

I can't immediately tell an obvious difference in the hexdump, so I wonder if
there's some kind of terminal signaling going on or not going on that's
changing how it's printed.

-- 
You are receiving this mail because:
You are the assignee for the bug.