How can you strip non-ASCII characters from a string in C# ?

Published on February 15, 2017 by abundantcode

Filed under C#

Last modified February 15, 2017

Print this page

rate 1 star rate 2 star rate 3 star rate 4 star rate 5 star
Your rating: none, Average: 0 (0 votes)

This article have been viewed 1331 times

Regular expressions is one of the easiest way to strip non-ascii characters from a string in C#. Here’s how you do it.

How can you strip non-ASCII characters from a string in C# ?

string input = "søme";
input = Regex.Replace(input, @"[^\u0000-\u007F]+", string.Empty);

Leave a Comment


x

You might be Interested in these Posts

Convert or cast integer to character in C#

Below is a sample sourecode demonstrating how to convert or cast int to char in C# Convert or cast ...

How to convert Ascii value to character in C# ?

In C# , you can convert the Ascii value to its corresponding character by assigning the value to a c...

How to decode a base64 string in C#?

Here's a sample code snippet demonstrating how you can easily decode a base64 encoded string in C#. ...