十六进制值 是无效的字符错误

产生原因是xml文件中包含低位非打印字符造成的

处理方法:在产生xml文件的时候,过滤低位非打印字符

public static string ReplaceLowOrderASCIICharacters(string tmp)
{
      StringBuilder info = new StringBuilder();
      foreach (char cc in tmp)
      {
        int ss = (int)cc;
        if (((ss >= 0) && (ss <= 8)) || ((ss >= 11) && (ss <= 12)) 
            || ((ss >= 14) && (ss <= 32)))
          info.AppendFormat(" ", ss);//&#x{0:X};
        else info.Append(cc);
      }
      return info.ToString();
}

原文地址http://www.cnblogs.com/lovko/archive/2008/12/26/1362838.html

相关文章:

  • 2022-01-01
  • 2021-08-08
  • 2022-12-23
  • 2021-06-29
  • 2021-12-04
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-08-20
  • 2021-08-18
  • 2022-12-23
  • 2022-12-23
  • 2021-07-23
  • 2022-12-23
  • 2021-08-10
相关资源
相似解决方案