Created
July 11, 2014 09:22
-
-
Save hervehobbes/dea1335d9d78a377f909 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private string removeNonAsciiChar(string content) | |
{ | |
content = Regex.Replace(content.Trim(), @"[^\u0000-\u007F]", string.Empty); | |
return Encoding.ASCII.GetString( | |
Encoding.Convert( | |
Encoding.UTF8, | |
Encoding.GetEncoding( | |
Encoding.ASCII.EncodingName, | |
new EncoderReplacementFallback(string.Empty), | |
new DecoderExceptionFallback() | |
), | |
Encoding.UTF8.GetBytes(content) | |
) | |
); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment