Back to Lo

Core Ellipsis

docs/data/core-ellipsis.md

1.53.0488 B
Original Source

Trims and truncates a string to the specified length in runes (Unicode code points) and appends an ellipsis if truncated. Multi-byte characters such as emoji or CJK ideographs are never split in the middle.

go
lo.Ellipsis("  Lorem Ipsum  ", 5)
// "Lo..."

str = lo.Ellipsis("Lorem Ipsum", 100)
// "Lorem Ipsum"

str = lo.Ellipsis("Lorem Ipsum", 3)
// "..."

str = lo.Ellipsis("hello 世界! 你好", 8)
// "hello..."

str = lo.Ellipsis("🏠🐶🐱🌟", 4)
// "🏠🐶🐱🌟"