restrictLengthWithEllipsis

fun String.restrictLengthWithEllipsis(maxLength: Int, ellipsis: String = "…"): String(source)

Shortens the string to maxLength; in such case, appends the ellipsis (typically "…" ).

For example, returns "ABCD…" when called for "ABCDEFHG".(5, "…")