using System; using System.Text; using System.Linq; using System.Diagnostics;
public static class Program
public static string UnicodeToANSI(this string s)
var sb = new StringBuilder();
sb.Append(s.Normalize(NormalizationForm.FormKD)
.Where(x => (x > 30 && x <= 255))
public static string ReducetoASCII(this string s)
StringBuilder sb = new StringBuilder(s.Length);
public static void Main()
Stopwatch sw = new Stopwatch();
string french = "A Paris, le cortège parisien s’était élancé à 14 heures.\r\n\tFace à l’affluence, un «itinéraire bis» a été mis en place. D’importants rassemblements ont lieu à Bordeaux, Marseille, Rennes ou Lyon. Suivez la journée avec nos journalistes dans toute la France.";
string ftemp = string.Empty;
string german = "ޘ Trump\t\r\nverwechselt Klägerin Carroll auf Foto mit Ex-Frau – das könnte Folgen haben";
string gtemp = string.Empty;
Console.WriteLine(french);
ftemp = french.ReducetoASCII();
Console.WriteLine("Ansi reduced\r\n" + ftemp + " in " + sw.ElapsedTicks);
ftemp = french.UnicodeToANSI();
Console.WriteLine("Proper Normalization\r\n" + ftemp + " in " + sw.ElapsedTicks);
Console.WriteLine(german);
gtemp = german.ReducetoASCII();
Console.WriteLine("Ansi reduced\r\n" + gtemp + " in " + sw.ElapsedTicks);
gtemp = german.UnicodeToANSI();
Console.WriteLine("Proper Normalization\r\n" + gtemp + " in " + sw.ElapsedTicks);