How Unicode normalization works in email-validator
mainThe library performs Unicode normalization to ensure that different but semantically equivalent strings are treated identically. This is critical for internationalized email addresses.
- Domain Normalization: Converts fullwidth/halfwidth characters to ASCII (via IDNA/Punycode) and applies Unicode NFC normalization.
- Local Part Normalization: Applies Unicode NFC normalization and removes unnecessary quotes or backslash-escaping in quoted-string local parts.
- Consistency: The
normalizedfield provides the consistent form you should use for database queries and storage to prevent duplicate accounts caused by different Unicode representations of the same address.
emailinfo = validate_email("me@Domain.com")
print(emailinfo.normalized)
print(emailinfo.ascii_email)
# prints "me@domain.com" twice