♻️ Extract the Storage service to DysonNetwork.Drive microservice

This commit is contained in:
2025-07-06 17:29:26 +08:00
parent 6a3d04af3d
commit 14b79f16f4
71 changed files with 2629 additions and 346 deletions

View File

@ -0,0 +1,33 @@
using System.Globalization;
using System.Text;
namespace DysonNetwork.Drive;
public abstract 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 text)
{
var category = CharUnicodeInfo.GetUnicodeCategory(ch);
// Keep whitespace and other specified control characters
if (category is not UnicodeCategory.Control || preserveControlChars.Contains(ch))
{
// Still filter out Format and NonSpacingMark categories
if (category is not (UnicodeCategory.Format or UnicodeCategory.NonSpacingMark))
{
filtered.Append(ch);
}
}
}
return filtered.ToString();
}
}