Skip to content

Commit 52ad90c

Browse files
authored
doc: Improve comment for lo.Ellipsis
1 parent f1dce8f commit 52ad90c

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

string.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,9 @@ func Capitalize(str string) string {
210210
return cases.Title(language.English).String(str)
211211
}
212212

213-
// Ellipsis trims and truncates a string to a specified length and appends an ellipsis if truncated.
213+
// Ellipsis trims and truncates a string to a specified length **in bytes** and appends an ellipsis
214+
// if truncated. If the string contains non-ASCII characters (which may occupy multiple bytes in UTF-8),
215+
// truncating by byte length may split a character in the middle, potentially resulting in garbled output.
214216
func Ellipsis(str string, length int) string {
215217
str = strings.TrimSpace(str)
216218

0 commit comments

Comments
 (0)