WEB Service 暴露的XML文档中存在低序位非打印 ASCII 字符

来源:互联网 发布:c#数组添加数据 编辑:程序博客网 时间:2024/05/19 16:49

System.InvalidOperationException was unhandled
  Message="XML 文档(1, 823)中有错误。"
  Source="System.Xml"
    Message="“”(十六进制值 0x0E)是无效的字符。 行 1,位置 823。"
    Source="System.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);
            else info.Append(cc);
        }
        return info.ToString();
    }