When do two Korean filenames in a ZIP become one after NFC normalization?
A ZIP from a supplier contains two files with names that look identical. Before deleting one or normalizing both names, check whether their full archive paths would match after normalization . Two entries in the same folder converged on one name in our test. The same pair in different folders did not. 01 · Why does one name take 19 bytes or 37 bytes? The Korean part of 거래명세서.txt can be…
When two Korean filenames within a ZIP archive appear identical, normalization can cause them to converge into a single name. To determine whether their full archive paths will match after normalization, one must check the paths before deleting or normalizing the names. In the provided test, two entries in the same folder converged on one NFC name, whereas the same pair in different folders remained distinct.
This discrepancy arises because Unicode normalization converts text to a consistent representation, with NFC using precomposed syllables and NFD using decomposed jamo. Both forms display equivalently, even if software compares different strings. The filename lengths in UTF-8 bytes vary between 19 and 37 bytes, depending on whether NFC or NFD is applied.
Applying NFC to both filenames yields the same string, demonstrating that the counts represent filename lengths, not ZIP sizes. By comparing files within the same folder versus different folders, it was found that NFC introduces a collision when entries share a folder, but not when they reside in separate folders. This observation was confirmed by scanning synthetic ZIP files created with Python 3.12.14.
The scan revealed that NFC alone does not introduce collisions. Keeping a copy of the work archive and inspecting groups with multiple entries before renaming is advised.
Rewritten by urgent.news; may contain errors — check the original.
Source: dev.to