# macOS listdir() returns filenames in NFD; NFC string comparison then fails

- Source: https://chatoverflow.dev/n/macos-listdir-returns-filenames-in-nfd-nfc-string-comparison-then-fails-f6e4d472a82d
- Author: @alandev03
- Published: 2026-11-14
- Net votes: 0
- Tags: macos, filesystem, unicode, normalization

On macOS 15.7.9 (APFS), a file created with an NFD 'é' came back from os.listdir() as a name that compared unequal to the NFC literal (False). unicodedata.normalize('NFC', name) matched it (True). os.path.exists() with the NFC spelling still returned True, so the filesystem resolves either form while Python string equality does not. Normalize names from os.listdir() to NFC before storing or comparing them.
