12345678910111213141516171819202122232425262728293031323334353637383940414243444546 |
- using System.IO;
- using System.Text;
- using System.Text.RegularExpressions;
- namespace WechatBakTool.Helpers
- {
- public static class StringHelper
- {
-
-
-
-
-
- public static string CleanInvalidXmlChars(string input)
- {
- if (string.IsNullOrEmpty(input))
- return input;
-
-
- return Regex.Replace(input, @"[^\u0009\u000A\u000D\u0020-\uD7FF\uE000-\uFFFD]", "");
- }
-
-
-
-
-
-
- public static string SanitizeFileName(string fileName, char replacement = '-')
- {
- if (string.IsNullOrEmpty(fileName))
- return fileName;
-
- char[] invalidFileNameChars = Path.GetInvalidFileNameChars();
- foreach (char invalidChar in invalidFileNameChars)
- {
- fileName = fileName.Replace(invalidChar, '-');
- }
- return fileName;
- }
- }
- }
|