Arezgitfield notes / engineering
Engineering practiceUPDATED NOV 23, 2026

Choose Unicode Normalization as an Identifier Policy

Distinguish canonical equivalence, compatibility mappings, and visual confusability, then migrate identifier comparison keys without silently merging records.

Arezgit Editorial4 min read
AREZGIT / FIELD NOTEENGINEERING PRACTICE
Two identifiers can look identical while containing different code point sequences. Normalization can make some equivalent sequences compare equally, but the chosen form also decides which d
READ / VERIFY / APPLYTECHNICALLY REVIEWED

Two identifiers can look identical while containing different code-point sequences. Normalization can make some equivalent sequences compare equally, but the chosen form also decides which distinctions the application preserves. Treat that choice as part of identifier identity, then check collisions before applying it to existing records.

This explanation uses JavaScript string examples executed in Node.js 24. It covers comparison keys for application identifiers, not a universal username standard or locale-aware search algorithm. Display text, canonical equality, case policy, and visual similarity remain separate decisions.

Separate display spelling from the comparison key

Unicode's normalization specification defines canonical forms such as NFC and compatibility forms such as NFKC. Canonical normalization can reconcile a composed accented character with its decomposed equivalent. Compatibility normalization additionally maps some distinctions that a product may or may not want to preserve.

Store the original accepted display spelling when that serves the interface, and derive a comparison key through one documented policy. A user-facing name can retain its appearance while uniqueness checks use the canonical key. Do not overwrite all display strings merely because a particular index needs normalization.

Case folding, trimming, punctuation removal, and transliteration are additional transformations. Calling the combined operation “normalization” hides which distinctions it removes. Specify the order and version of each transformation if the identifier policy requires more than a Unicode normalization form.

An identifier policy also needs an allowed repertoire and length rule. Decide whether limits concern encoded bytes, code units, code points, or user-perceived characters. A normalization operation does not establish those limits or guarantee that a rendered name will fit a particular layout.

Compare three distinct kinds of similarity

Run the following module with Node.js. Each pair demonstrates a different boundary:

import assert from "node:assert/strict";

const composed = "caf\u00e9";
const decomposed = "cafe\u0301";
assert.notEqual(composed, decomposed);
assert.equal(composed.normalize("NFC"), decomposed.normalize("NFC"));
assert.notEqual("\uff21".normalize("NFC"), "A");
assert.equal("\uff21".normalize("NFKC"), "A");
assert.notEqual("\u0430".normalize("NFKC"), "a");

The accented strings become equal under NFC. The fullwidth Latin capital A remains distinct under NFC but maps to ordinary A under NFKC. The Cyrillic small letter a remains different from Latin a even under NFKC. These observations make it possible to discuss the policy without relying on how a particular font happens to render the characters.

Unicode's security mechanisms specification treats confusable detection as a separate subject. Normalization alone is not an impersonation defense. A product handling account names may need a maintained identifier profile, script restrictions, or a review process appropriate to its audience; implement that through established Unicode guidance rather than an improvised list of lookalikes.

Do not use a visual-confusable key automatically as the unique account identifier. Similar appearance can be useful as a warning without establishing that two users or organizations are the same entity. Preserve that distinction in support and account-recovery tools too.

Apply one equality policy at every authoritative boundary

Suppose registration checks the original string while login normalizes it. Two registrations can be accepted as distinct and then resolve to the same lookup key. The problem is inconsistent authority, even if each individual string operation works as documented.

Derive the comparison key before the authoritative uniqueness decision. Store and query it consistently, including updates, imports, administrative tools, and external identity links. A browser-side preview can help explain a collision, but the server and storage constraint must decide whether the identifier is available.

Avoid relying on a database collation without checking its equality semantics against the application's policy. A collation can be case- or accent-insensitive in ways that differ from the explicit JavaScript transformation. Test representative pairs through the actual storage adapter before claiming end-to-end uniqueness behavior.

For denied registration or renaming, leave the existing record unchanged and offer a bounded explanation. Do not expose private account details just to explain that a comparison key is occupied. A collision response can be useful without identifying the owner of the conflicting record.

Migrate old identifiers as a collision investigation

Before enforcing a new key, compute it for existing records in an isolated review process and group records by candidate key. Distinguish groups with one record from groups with multiple independent owners. The latter require a product decision, not an automatic merge.

Use the accented pair from the fixture as a synthetic migration case. Under the old bytewise policy, both records could exist. Under NFC equality, they collide. Automatically assigning one record's key to the other would change lookup and possibly account authority. Preserve identifiers and ownership while resolving the naming conflict through a deliberate process.

Plan concurrent writes during migration. If new records can still use the old policy while keys are being backfilled, the final constraint may fail or miss an earlier decision. Coordinate writers through the supported migration mechanism and test an attempted duplicate during the transition.

Keep a versioned policy record and recheck when runtime Unicode data or storage behavior changes. The general compatible migration guide covers rollout sequencing; this migration adds a semantic question about equality. Finish only when creation, lookup, renaming, and recovery all use the same intended identity rule and every preexisting collision has an explicit resolution.

READER SIGNAL

Was this guide useful?

Your rating helps us prioritize clearer, more practical technical content.

AREZGIT / DESKTOP WORKSPACEFROM FIELD NOTE TO RELEASE

Review diffs, run checks, and prepare the release in Arezgit.

Keep Git review, security scanning, API checks, database inspection, and release preparation together in one local desktop application.

Explore Arezgit