TL;DR: Write an equivalence policy before normalizing search input. Build paired examples that should match and examples that must stay distinct. Inspect the exact characters, run the query and indexing paths together, and keep original text available for display, diagnosis and any supported migration.
Decide what equality means for this field
A search box, a display name and an account identifier can have different requirements. Helping someone find a record does not automatically authorize merging two records or treating two identifiers as the same principal.
Unicode Standard Annex #15 defines canonical and compatibility normalization forms. The important application decision is which distinctions your task may discard. The annex explicitly cautions against blindly applying compatibility normalization to arbitrary text.
Begin with actual permitted examples from the intended language and field, then add synthetic edge cases. Do not choose a transform merely because it makes an example return more results. A broader match can also create a wrong match.
Inspect characters instead of trusting appearance
Two strings can look alike while containing different code points. Record an escaped form or code-point sequence for a small diagnostic fixture, with private content removed.
For example, precomposed é is U+00E9. An e followed by a combining acute accent is U+0065 followed by U+0301. A screenshot alone is a poor way to distinguish them.
Python's unicodedata documentation describes normalization and exposes the runtime's Unicode database version. Save the relevant library, database and version with a test; reading the current specification is not proof that an older deployed runtime implements every newer character.
Keep diagnostics bounded. A search debug log does not need an entire private document or an unrestricted user query history to explain one character difference.
Reproduce a small normalization fixture
We ran the following synthetic pairs locally with Python's Unicode database version 16.0.0. They are teaching examples, not a search-quality benchmark or a conformance claim for a later Unicode version.
- Precomposed
caféandcafefollowed by U+0301 are unequal as raw strings. They compare equal after NFC and after NFKC. - Fullwidth
ACMEand ASCIIACMEremain different after NFC but compare equal after NFKC. - Circled digit
①and ASCII1remain different after NFC but compare equal after NFKC. Whether the application should combine their records is still a separate question. - Latin
a(U+0061) and Cyrillicа(U+0430) remain different after both NFC and NFKC.
The normalization results are reproducible observations about these inputs. They do not decide the product's desired matching policy. In particular, a compatibility mapping can be useful for one search task and inappropriate for a field where a distinction is meaningful.
Keep the expected matches beside the fixture, not only the transformed strings. Otherwise a test can stay green while the intended meaning quietly changes.
Separate normalization from other search choices
Case folding, accent handling, punctuation removal, tokenization and ranking are separate decisions. Naming the whole pipeline normalization can hide which step caused a collision.
Python's casefold reference describes a case-insensitive transformation. In our local fixture, "ß".casefold() produced ss. That is not an instruction to rewrite every displayed name or to apply the same identity rule in every language.
Similarly, deleting all punctuation and lowercasing maps both C and C++ to c. That result comes from the deletion rule, not from NFC or NFKC. If those inputs name different products in a catalog, a test must preserve the difference somewhere in matching or disambiguation.
Evaluate each proposed step independently before testing the combined pipeline. Keep an explanation for why a changed match is acceptable, rather than treating the number of matches as the only score.
Test query and index behavior together
Use a disposable collection with stable record identities, original text and the candidate indexed representation. Include both intended equivalent forms and deliberately distinct neighbors.
For each query, record the expected identities, returned identities and any ambiguous result. Check at least:
- The two intended equivalent inputs retrieve the required record under the declared policy.
- A neighboring identifier does not silently become the same stored object.
- Token boundaries and punctuation survive where the task requires them.
- An empty or unsupported input remains distinguishable from a completed search with no matches.
- The display preserves the intended original text rather than exposing an unexplained transformed value.
- The deployed query path and index use compatible transformations and versions.
Search matching can intentionally return several candidates for review. That is different from using the same normalized value as a unique account key. Do not let a convenient retrieval transform silently become an authorization rule.
Treat confusables as a separate investigation
Unicode Technical Standard #39 addresses identifier security and confusable mechanisms. A normalizer does not turn every visually similar string into the same string or establish that an identifier is safe.
For the permitted identifiers your product accepts, define the relevant script, display and review policy. Preserve uncertainty when a diagnostic cannot establish intent. A mixed-script test fixture is useful evidence about one path; it is not grounds to label all multilingual names malicious.
Plan a change with collision and rollback evidence
Before changing persisted keys, inspect collisions under the candidate policy in an authorized, bounded environment. Decide how existing distinct identities are handled; do not automatically merge them because a transformed value matches.
Keep the previous representation or another supported recovery path while testing the new version. Compare results on the same declared fixture and record which retrieval behavior changed. A successful rebuild alone does not show that the new matches are desirable.
The paginated-reader guide can help collect a bounded source set without hiding gaps. The research guide helps distinguish a reported search failure from a proposed explanation. The useful outcome is a checked equivalence policy and reproducible matching behavior, not a promise that one transform fixes every language or every search problem.