Code Snip: Removing non ASCII characters in C#



 

C# Tip. To make sure you clean your string from non ASCII characters you can use Regex class instead of using string functions. The [\x01-\x1F] is the range you want to keep.

temp = Regex.Replace(temp, "[\x01-\x1F]", "");

Happy coding.

Cheers

Al

Follow me in twitter | bookmark me | Subscribe to my feed | Add stats to your blog

Published Friday, January 15, 2010 7:30 PM by albertpascual
Filed under:

Comments

No Comments

Leave a Comment

(required) 
(required) 
(optional)
(required)