hexadecimal value 0x0C, is an invalid character-如何去除XML无效字符

public static string CleanInvalidXmlChars(string text)  
  {  
      // From xml spec valid chars:  
      // #x9 | #xA | #xD | [#x20-#xD7FF] | [#xE000-#xFFFD] | [#x10000-#x10FFFF]    #x2  
      // any Unicode character, excluding the surrogate blocks, FFFE, and FFFF.  
      string re = @"[^\x09\x0A\x0D\x20-\xD7FF\xE000-\xFFFD\x10000-x10FFFF]";  
      return Regex.Replace(text, re, "");  
  } 

本文来自CSDN博客,转载请标明出处:http://blog.csdn.net/yls087412/archive/2009/10/29/4743320.aspx

你可能感兴趣的:(character)