This commit is contained in:
toom1996
2026-08-26 10:45:21 +08:00
parent 3cf1368e68
commit 30c9f21da4
48 changed files with 3442 additions and 0 deletions

View File

@ -0,0 +1,13 @@
// Package textutil 提供文本处理辅助函数。
package textutil
// Summarize 按 rune 截断字符串,避免中文被按字节切断;超出部分追加省略号。
//
// 行为与原项目 handlers.summarize 完全一致(含省略号字符 U+2026)。
func Summarize(s string, n int) string {
runes := []rune(s)
if len(runes) <= n {
return s
}
return string(runes[:n]) + "…"
}