Documentation
¶
Overview ¶
Package textutil provides text manipulation and encoding utilities.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func EnsureUTF8 ¶
EnsureUTF8 ensures a string is valid UTF-8. If already valid UTF-8, returns as-is. Otherwise attempts charset detection and conversion. Falls back to replacing invalid bytes with replacement character.
func FirstLine ¶
FirstLine returns the first line of a string. Useful for extracting clean error messages from multi-line outputs. Leading newlines are trimmed before extracting the first line.
func GetEncodingByName ¶
GetEncodingByName returns an encoding for the given IANA charset name.
func SanitizeUTF8 ¶
SanitizeUTF8 replaces invalid UTF-8 bytes with replacement character.
func TruncateRunes ¶
TruncateRunes truncates a string to maxRunes runes (not bytes), adding "..." if truncated. This is UTF-8 safe and won't split multi-byte characters.
Types ¶
This section is empty.