How to remove accents in .NET easily

This code shows you how to remove accents in .NET without effort.

string text = "áóéíóúãõâêîôûç";
byte[] bytes = System.Text.Encoding.GetEncoding("Cyrillic").GetBytes(text);
string removedAccents = System.Text.Encoding.ASCII.GetString(bytes);

Nice, huh? By using that method you don’t need to create a bunch of regular expressions and worry about every possible accent you have to remove.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s