iberezh
← All writing
· Unicode

Two users sign up as "José"

Two users sign up as "josé". Your database may happily accept both.

It's not a database bug. The two names really are different strings: one stores é as a single character, the other as e plus a separate accent mark. They look identical on every screen. In code, they're not equal.

Where this bites: - unique usernames or emails that aren't unique - search that can't find a word that's right there - character limits that count 5 where a person sees 4

The fix is one call at the edge of your system. Normalize text as it comes in, before you store or compare it: str.normalize("NFC") in JavaScript, unicodedata.normalize("NFC", s) in Python.

Discussion on LinkedIn