Yet another reason I dislike Apple. Well, I've had many reasons, and this one is...
Alex Schroeder @alex@social.alexschroeder.ch
Yet another reason I dislike Apple. Well, I've had many reasons, and this one is not a new reason, it just manages to bite me in a new way. Apple uses the HFS+ filesystem. It stores filenames in a Unicode encoding using normal form D (NFD). Everybody else apparently uses normal form C (NFC). This matters because when you meet a non-ASCII character that has multiple representations as bytes, NFD and NFC use different bytes. As an example, consider the humble heavy metal a, ä.
NFC uses
ä LATIN SMALL LETTER A WITH DIAERESIS
NFD uses
COMBINING DIAERESIS
plus
a LATIN SMALL LETTER A
Anyway, this just sets the scene. On a Linux system the ext4 filesystem says that filenames are just bytes. Nobody cares about encodings. So whatever tool was used to generate the filename, its encoding determines the bytes used. For example, I buy music on Bandcamp and the filenames contain some bytes. I copy them to an external drive. This external drive, sadly, is mounted by an Apple laptop using HFS+. It's smart. It recognises the bytes. It's UTF-8 NFC! It saves them as NFD. Because it's smart.
Since I'm also smart, I keep the music files on an SD card of my little laptop, and on the SD card of the music server, and probably in a few other places. All of these filesystems are not smart. The filenames are just bytes that happen to encode the names using UTF-8 NFC. I am not smart.
After a while I wonder whether I forgot to sync new files to the external drive and I run a tool. I might use rsync, for example. And of course it thinks that all the remote files with NFD encoded filenames should be deleted and all the local files with NFC encoded filenames should be added. But the content of the files is identical.
Actually, you say, what about the --iconv option to rsync. It does just that, convert the filenames from one encoding to another. Ah, I say, Apple doesn't like GNU and so they have a version of rsync that doesn't support this option.
And next we're into self-compiling a new rsync, or installing Homebrew, and at that point I'll say, see, yet another reason I dislike Apple.
For more fun stuff about #Unicode consider https://transmom.love/@elilla/117123811283842800