如何在 xml c# 中删除非 ASCII 字符,如倒置的"T"、"L"等
我试过像清理XML字符串一样
(character >= 0x20 && character <= 0xD7FF) ||
(character >= 0xE000 && character <= 0xFFFD) ||
(character >= 0x10000 && character <= 0x10FFFF)
并按如下方式使用正则表达式:
Regex.Replace(inputText, @"[^><#w.@-]", "");
(or)
string str = str.replace(/[^A-Za-z 0-9 .,?""!@#$%^&*()-_=+;:<>/\|}{[]`~]*/g, '')
和模式替换如下:
string pattern = @"#x((10?|[2-F])FFF[EF]|FDD[0-9A-F]|7F|8[0-46-9A-F]9[0-9A-F])";
最后是
XmlConvert.VerifyXmlChars(text);
但是没用,字符如下所示:"┌"├"⌐"┐"┴"
请参阅此链接https://en.wikipedia.org/wiki/Western_Latin_character_sets_%28computing%29
└ U+2514 C0 C0
┘ U+2518 D9 D9
请帮我摆脱困境。提前致谢
Try This
string s = "søme string";
s = Regex.Replace(s, @"[^u0000-u007F]", string.Empty);