Regular expressions and text guides
Full-width conversion and NFKC: different normalization scopes
Convert full-width ASCII deliberately and avoid broad compatibility normalization where identity must be preserved.
Convert the intended characters
Full-width ASCII letters and digits have recognizable narrow counterparts. A converter can also map the ideographic space to ordinary space.
Use the site's width converter on a short fixture and check each changed character before applying it to identifiers.
ABC123 → ABC123 NFKC covers more than width
Compatibility normalization can convert ligatures, enclosed digits and other compatibility forms as well as width variants.
A width-only conversion and normalize NFKC therefore need not produce the same result. Choose the scope required by the data contract.
'①'.normalize('NFKC') → '1'
This is a compatibility mapping, not only a width change.Detect new collisions
Two distinct stored strings can normalize to one result. In a username or route namespace, that can create a collision.
Check the complete collection before adopting a normalization policy and define whether collisions are rejected or migrated.
Preserve original display text
Search normalization may be useful while the original display name remains unchanged. Store those roles separately when the product needs both.
Do not normalize passwords or externally signed text opportunistically; both sides must agree on the exact preprocessing rule.