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