Documentation
¶
Overview ¶
Package textutil cuts text to a budget measured in runes.
A byte budget applied to non-ASCII text is wrong twice over: it keeps far less than it promises, and it can end mid-rune, which JSON encoding then rewrites as U+FFFD. Every limit here counts runes and every cut lands on a rune boundary, so the output is always valid UTF-8.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func TruncateMiddle ¶
TruncateMiddle keeps the head and tail of s within limit runes and drops the middle, returning the kept text and how many runes it removed so a caller can say how much is missing.
func TruncateMiddleParts ¶
TruncateMiddleParts keeps a head and a tail of s within limit runes, drops everything between them, and reports how many runes it dropped. The budget goes two thirds to the head and one third to the tail. Callers that mark the seam need the two pieces; TruncateMiddle is the same cut already joined.
func TruncateRunes ¶
TruncateRunes returns the first limit runes of s. A limit of zero or less keeps nothing.
Types ¶
This section is empty.