Skip to content
Tracon

TextTrimming

Namespace Tracon · Assembly Tracon.Core.dll

Trims text to a UTF-8 byte limit.

public static class TextTrimming

objectTextTrimming

object.GetType(), object.MemberwiseClone(), object.ToString(), object.Equals(object?), object.Equals(object?, object?), object.ReferenceEquals(object?, object?), object.GetHashCode()

Pure and stateless. Used both to bound a tool’s result (TruncatingAIFunction) and an MCP resource’s content (Tracon.Mcp).

Trims text to a UTF-8 byte limit. Never cuts in the middle of a multi-byte character; in that case, the whole character is dropped.

public static (string Text, bool Truncated) Trim(string text, int maxBytes)

text string

The text to trim.

maxBytes int

The maximum byte limit.

(string Text, bool Truncated)

The trimmed text and whether trimming occurred.