Use Unicode NFC to produce a ZIP archive whose member names spell equivalent accented characters in a consistent way. Inspect the code points in those stored names, then compare a sample member with its source file. Filename normalization leaves document text alone. A ZIP works for this exercise because it provides a name you can inspect before the receiving filesystem makes its own naming decisions.
The script prepares a flat set of regular files from one local source folder. It previews each visible name in escaped form, checks for collisions, and writes a new archive only after confirmation. The sample has a document called café with an acute accent, an ordinary ASCII file, and another accented label. Put the original files in a stable practice folder so you can compare the archive with a known source.
Understand what a different spelling can mean
The letter in café can be represented by a single precomposed Unicode character, or by the letter e followed by a combining acute accent. The resulting display can look the same. A program that compares the two underlying sequences without normalizing them can treat the paths as different. This can matter when a receiving system associates a filename with a record or looks for a particular exact string.
NFC uses canonical decomposition and composition rules to give canonically equivalent sequences a consistent representation. In this example the output uses the precomposed lowercase accented e. The script calls Python’s Unicode normalization function with NFC. It keeps the original meaning and visible spelling. Other forms, including NFKC, can apply compatibility conversions that are different from this goal. Pick the form required by the receiving system rather than changing filenames until they look simpler. Python Unicode normalization.
To see the difference independently of the filesystem, run the short Python example below. It constructs both versions explicitly. For the first spelling, Python should report a single U+00E9 at the end. For the second, it should report U+0065 followed by U+0301. The raw strings differ while the normalized strings compare equal. This test uses only in-memory text, so it works even on a volume that will not let you store both names side by side.
import unicodedata
composed = "caf\u00e9"
decomposed = "cafe\u0301"
for original in (composed, decomposed):
print(ascii(original), [f"U+{ord(char):04X}" for char in original])
print(composed == decomposed)
print(unicodedata.normalize("NFC", composed) == unicodedata.normalize("NFC", decomposed))
The name you typed, the name Python enumerates from the folder, and the name stored in a ZIP can be observed separately. macOS can present equivalent-looking names using a filesystem-dependent representation. Finder is a good place to open a document, but its visual display gives little evidence about the underlying code points. The script prints the sequence it received from the source directory and the sequence it plans to use for the archive.
Use a fixture whose contents you can recognize
Create a folder named Handoff Originals and put three small text files in it. Use the names café.txt, Résumé.txt, and inventory.txt. Put a different synthetic sentence in each. For example, the café file can contain Blue counter opens at nine, the résumé file can contain Draft of techniques list, and the inventory can contain Four test clips. The distinct contents let you check that the mapping preserved the right file as well as the right spelling.
Save the full Python script below as nfc_zip.py. Use Python 3.9 or later. Place the proposed ZIP in a directory outside your input. Choose a filename that does not already exist and a parent directory that does. Both arguments are absolute paths in this example. Keep the source separate from the finished archive so a later run can see the original documents without pulling its earlier output into the next handoff.
python3 nfc_zip.py "/absolute/path/to/Handoff Originals" "/absolute/path/to/Normalized Delivery.zip"
Read the plan. An item may be shown with Python’s escaped notation, for example the café spelling can show a hexadecimal escape for a single accented character rather than the drawing you see in Finder. The ASCII name should have the same escaped spelling on both sides. If an accented name already has the target representation, it too can be identical across the reformatting step. That is a valid outcome.
The script skips dot-prefixed items, subdirectories, and symbolic links. If a document was stored inside another folder, it will not be present here. Bring only the selected independent files to the input folder. Avoid app bundles or other packages whose directory relationships are important. The flat archive intentionally has just one member level. Write down the expected count and check it against the displayed plan before confirming.
Use the collision check before creating a ZIP
The script uses a case-folded NFC string as a conservative comparison key. It stops when two input files would use conflicting keys, so it does not choose a winner based on sort order. A receiver that distinguishes case could technically keep both, but the intended handoff uses names that remain distinct on less permissive systems. The comparison is a rule for this package, and a receiving app can still impose other restrictions.
On a source volume that allows two files with case variants, consider adding Sample.txt and sample.txt to a different scratch test. Give the two files different content first. The expected result is a collision error before any ZIP appears. Some volumes will not allow creating both names in a single folder. In that case you can still demonstrate the string comparison separately and keep the real folder’s tested archive as your verification. Do not rely on Finder’s willingness to display two names as evidence of what another system accepts.
When a collision exists in the real package, give the entries distinct descriptive names in a working copy. A pair of same-looking files might be versions from different authors, for example. Preserve or record those identities before deciding how to name the deliverables. Normalization can make a text key comparable, but it cannot decide which file the recipient needs.
Read the exact member names and verify the content
After reviewing the plan, enter ZIP. The script writes a new archive and reopens it. It verifies the member-name list against the plan and checks each member’s CRC. That is useful evidence that the resulting archive is readable. Compare a known sample’s archive bytes with the matching source file where you need evidence of identity. Python’s archive API lets you read one member without first extracting a possibly differently represented filename onto disk. Python ZIP archive operations.
The following readback checks each stored member for NFC and prints its name in escaped form. It then compares the bytes of one named member with the original file from the source folder. Use the actual original path if the accent is displayed differently when you construct that path. You can drag the source file into Terminal to learn the shell path representation before setting your own arguments.
python3 - "/absolute/path/to/Normalized Delivery.zip" "/absolute/path/to/Handoff Originals/café.txt" <<'PY'
from pathlib import Path
import sys
import unicodedata
import zipfile
archive, source = (Path(value) for value in sys.argv[1:])
with zipfile.ZipFile(archive) as bundle:
for name in bundle.namelist():
print(ascii(name), unicodedata.is_normalized("NFC", name))
assert bundle.read("caf\u00e9.txt") == source.read_bytes()
print("The café document contents match.")
PY
Check that all displayed normalization results are true and that the output includes the expected sample content match. The archive CRC check confirms that the file data can be read and passes its stored integrity marker. It does not determine which version of a document should have been archived. The source sentence and optional byte comparison give you that separate connection.
Confirm the destination system’s own result
Send or copy the archive only after you have checked the stored names and expected member count. Where an importing system requires exact NFC, ask it to report the name it receives or independently inspect the destination’s enumerated filename. An archive member name can conform even if a destination volume presents a different string after extraction. When the recipient reports that a document finder still misses café, compare the actual name seen by the importer with its lookup key. A string mismatch at that stage points to how the destination handles names.
Keep the original set until the receipt is verified. If archiving stops partway, keep that ZIP apart from the intended delivery and choose a fresh destination after fixing the cause. Compare normalizing one archived name with preserving document contents and with how the receiver stores files. These separate checks turn a visual filename issue into a concrete observation you can reproduce.
Standalone archive script
# Run: python3 nfc_zip.py "/path/to/documents" "/path/to/new-delivery.zip"
from pathlib import Path
import sys
import unicodedata
import zipfile
source, output = (Path(arg).resolve() for arg in sys.argv[1:])
if not source.is_dir() or output.is_relative_to(source) or output.exists():
raise SystemExit("Choose a new archive outside the source directory.")
plan = []
seen = set()
for path in sorted(source.iterdir()):
if path.is_symlink() or not path.is_file() or path.name.startswith("."):
continue
name = unicodedata.normalize("NFC", path.name)
key = name.casefold()
if key in seen:
raise SystemExit(f"Names would collide on a case-insensitive target: {name!r}")
seen.add(key)
plan.append((path, name))
print(ascii(path.name), "->", ascii(name))
if not plan or input("Type ZIP to write this archive: ") != "ZIP":
raise SystemExit("Stopped.")
with zipfile.ZipFile(output, "x", compression=zipfile.ZIP_DEFLATED) as bundle:
for path, name in plan:
bundle.write(path, arcname=name)
with zipfile.ZipFile(output) as bundle:
if bundle.namelist() != [name for _, name in plan] or bundle.testzip() is not None:
raise SystemExit("Archive verification failed. Keep the source folder.")
print("Archive names and member CRCs checked.")
Compare the filenames at each boundary
Put down three observations when making a handoff to another program. First, record the escaped names the script discovered in the local folder. Second, capture the normalized member names you read directly from the ZIP. Third, if you can inspect the destination, record what its file listing or importer actually reports after opening the archive. These stages can have different results for the same visible label. For a developer matching a caption file to a record name, the third observation is often the one that controls whether the match succeeds.
For example, a Mac practice folder might expose the café filename as a decomposed sequence before archiving. Python can report a composed sequence inside the archive. The import service might store the member under the same composed name, copy it to another disk with a different representation, or use its own case comparison. Keep the actual diagnostic output as text rather than comparing two screenshots. A browser or Finder can render the sequences the same way. An exact character comparison in the program that matches the key resolves more uncertainty.
Ask how the recipient creates its lookup keys. An upload service might take apartment or invoice names from a CSV while using original ZIP member names for the imported files. In that situation the filenames can all be valid NFC and still fail a match if the CSV contains different code points. A test pair with the café document and one lookup record lets you verify both values independently using the same normalization requirement. For the file check, leave the document bytes alone. For the lookup record, apply the recipient’s required format before testing.
Separate case sensitivity from accent normalization
The first file can differ from another in two ways at once. Imagine the first name is lowercase café in decomposed form while the second starts with uppercase C and uses a composed accent. NFC changes how the accent is represented, and case folding makes the two spellings compare alike for the collision check. The actual archive would retain the selected original capitalization after normalization. The comparison key is used for deciding whether two items can safely coexist in the set.
A source where case matters can contain separate drafts called Résumé.txt and résumé.txt. Suppose their contents identify different departments. In a staging folder, give them role labels such as editorial and design before preparing the archive. That way the names remain useful to a recipient even if their filesystem handles case differently. Write any renamed draft’s original role into the handoff record so the work does not depend on remembering how the accented letters originally appeared.
Finally, match every member to your source manifest before archiving a real project. The code applies NFC to names without modifying document contents or checking references inside those documents. If a sidecar lists exact filenames, update its working copy where the new archive names require it and test one actual lookup. That preserves the benefits of a normalized package while leaving the input set available for recovery if another part of the workflow expects its original names.