package util

import "strings"

// TruncateStr truncates a string to maxLen runes, appending "..." if truncated.
func TruncateStr(s string, maxLen int) string {
	s = strings.TrimSpace(s)
	if maxLen <= 0 {
		return ""
	}
	runes := []rune(s)
	if len(runes) <= maxLen {
		return s
	}
	return string(runes[:maxLen]) + "..."
}
