A build broke on CI last week and passed on my laptop. Same commit, same Node version. The cause was a filename that existed in two spellings which look identical on screen.
é has two valid encodings in Unicode:
NFC (precomposed): U+00E9 , one code point
NFD (decomposed): e + U+0301 (combining acute accent), two code points
Both render as é. Neither is wrong — both forms are valid, and macOS APIs will hand you either one depending on where the name came from: Finder, a zip archive, a copy out of Photoshop, a pasted filename.
The numbers:
a = "caf\u00e9" # NFC b = "cafe\u0301" # NFD len ( a ) , len ( b ) # (4, 5) len ( a . encode ( ) ) , len ( b . encode ( ) ) # (5, 6) a == b # False unicodedata . normalize ( "NFC" , a ) == unicodedata . normalize ( "NFC" , b ) # True hashlib . sha256 ( a . encode ( ) ) . hexdigest ( ) [ : 12 ] # 850f7dc43910 hashlib . sha256 ( b . encode ( ) ) . hexdigest ( ) [ : 12 ] # 81ef060bcd98
Enter fullscreen mode
Exit fullscreen mode
Two hashes for one name.…