How do I view the bytes of a filename as it’s stored an APFS volume (i.e. without going through Unicode normalization)?
Context: I migrated an old iTunes library to a new Music.app library, and ran the "Consolidate files" operation on the result to tidy things up. Then I used rsync
and diff
to compare the two on disk and got results like:
% diff -rq iTunes/iTunes\ Music Music/Media.localized/Music
...
Only in Music/Media.localized/Music: Múm
Only in iTunes/iTunes Music: Múm
This led me down the path of learning about Unicode normalization (explainers here and here). Those two strings have the same visual representation but are stored differently on disk. This comes up frequently with accented characters.
The question that arose was: How do I quickly get the on-disk byte representation of each name, so that I can be confident I understand what is going on?
BTW, for the original problem of comparing directories, I found this handy Python script (via this answer) which will consider Unicode-equivalent names as matching.