Reputation: 21013
So I'm trying to create a lower case version of an email however, I'm wondering if culture will have an affect.
public class aspnet_Membership
{
//...
public Email { get; set; }
public LoweredEmail { get; set; }
}
Currently I'm just calling .ToLower() like so:
this._user.aspnet_Membership.Email = value;
this._user.aspnet_Membership.LoweredEmail = value?.ToLower();
I know there are casing issues in some languages, I haven't investigated the emca spec for email addresses. Is this safe to do, or do I need to use CultureInvariant or will there always be cases where domain names will transform wrong etc?
Upvotes: 1
Views: 1169
Reputation: 12050
You can use the following approach for making lowercase all the letters of each word by using
CultureInvariant
:
text = string.IsNullOrEmpty(text) ? string.Empty :
text.ToLower(new CultureInfo("en-US", false));
Upvotes: 1