Skip to content

Instantly share code, notes, and snippets.

@ugurhasar
Last active July 16, 2018 20:14
Show Gist options
  • Save ugurhasar/346a08d2bbb37ecb24752e19c7a1cd51 to your computer and use it in GitHub Desktop.
Save ugurhasar/346a08d2bbb37ecb24752e19c7a1cd51 to your computer and use it in GitHub Desktop.
XML Remove Illegal Unicode Characters
public static string CleanInvalidXmlChars(this string text)
{
return Regex.Replace(text, @"[^\x09\x0A\x0D\x20-\xD7FF\xE000-\xFFFD\x10000-x10FFFF]", string.Empty);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment