🚚 Move packages

This commit is contained in:
2025-09-27 16:30:35 +08:00
parent 9ce31c4dd8
commit 78f8a9e638
8 changed files with 7 additions and 12 deletions

View File

@@ -0,0 +1,27 @@
using System.Globalization;
using System.Text;
namespace DysonNetwork.Shared.Data;
public abstract partial class TextSanitizer
{
public static string? Sanitize(string? text)
{
if (string.IsNullOrEmpty(text)) return text;
// List of control characters to preserve
var preserveControlChars = new[] { '\n', '\r', '\t', ' ' };
var filtered = new StringBuilder();
foreach (var ch in from ch in text
let category = CharUnicodeInfo.GetUnicodeCategory(ch)
where category is not UnicodeCategory.Control || preserveControlChars.Contains(ch)
where category is not (UnicodeCategory.Format or UnicodeCategory.NonSpacingMark)
select ch)
{
filtered.Append(ch);
}
return filtered.ToString();
}
}