Decoder94 Decoder94 -4 years ago 92
C# Question

How to keep accented character, letters numbers and symbols

How to keep letters, numbers, symbols and accented characters c#. I would like to get rid of emojis and the "最高" characters. This works but it is ignoring new lines.

string Message = @"The cédille (cedilla) Ç ...The Accent aigu (acute accent) é ...
The Accent circonflexe (circumflex) â, ê, î, ô, û ...
The accent grave (grave accent) à, è, ù ...
The accent tréma (dieresis/umlaut) ë, ï, ü" 最高

Answer Source

It seems to me you only want to keep the ASCII characters, and not all other character set (like UTF-8/16) characters.

This would do:

string msg = new string(Message.Where(c => ((int)c) < 256).ToArray());
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download