Table of Contents

Class TextSanitizer

Namespace
SharpConsoleUI.Helpers
Assembly
SharpConsoleUI.dll

Provides sanitization for text entering the character buffer. Prevents terminal escape injection by filtering control characters, BiDi overrides, and other unsafe runes before they reach cells.

public static class TextSanitizer
Inheritance
TextSanitizer
Inherited Members

Fields

ReplacementCharacter

The replacement character used when an unsafe rune is encountered.

public static readonly Rune ReplacementCharacter

Field Value

Rune

Methods

IsSafeCombiner(Rune)

Returns true only for runes that are legitimately zero-width and safe to attach as combiners. This includes Unicode categories Mn (nonspacing mark), Me (enclosing mark), Mc (spacing combining mark), and Cf (format) minus BiDi overrides, plus VS1-VS16, ZWJ (U+200D), ZWNJ (U+200C), emoji skin tone modifiers (U+1F3FB-U+1F3FF), and regional indicator symbols (U+1F1E6-U+1F1FF).

public static bool IsSafeCombiner(Rune r)

Parameters

r Rune

Returns

bool

IsUnsafeRune(Rune)

Returns true if the rune must never reach a cell in the character buffer. This includes C0/C1 control characters, DEL, BiDi overrides, surrogates, and noncharacters.

public static bool IsUnsafeRune(Rune r)

Parameters

r Rune

Returns

bool

SanitizeRune(Rune)

Returns the rune unchanged if safe, or U+FFFD if it is unsafe.

public static Rune SanitizeRune(Rune r)

Parameters

r Rune

Returns

Rune