Fixing UTF-8 filename encoding from macOS to OpenBSD

       183 words, 1 minutes

When detarring an archive file made on macOS onto OpenBSD, I got a bunch a files with “wrong” encoding name. And that even screwed up my Nextcloud synchronization. But there is a way to solve this.

So the other day, I launched “Photos” on macOS and use the export function to get all my medias out of this software. Then I opened a Terminal and issued a

tar cpf Photothèque.tar PhotothèqueExport

Then I transferred the tarball to OpenBSD and issued the extract command:

tar xpf Photothèque.tar

I noticed that extracted filenames had weird accented characters but didn’t realize that those would issue errors when the Netxcloud client would synchronize them.

What happens is that macOS generates filename using normalization form D (NFD). When decent OSes use normalization form C (NFC). So I would have to convert the filenames to the proper normalization:

# doas pkg_add convmv

# convmv -f utf8 -t utf8 --nfc --notest -r PhotothèqueExport
Ready! I converted 2031 files in 72 seconds.

And now, my files have proper filename encoding and can be used and synchronized on my OpenBSD machines.