Truncates a string to a specified length and adds ellipsis if needed.
The input string.
The maximum length.
The string to append (default: "...").
The truncated string.
Truncates a string to a specified length and adds ellipsis if needed.