truncateToByteLength

fun String.truncateToByteLength(desiredByteLength: Int): String

Truncates and returns the input text to the desired number of UTF-8 bytes.

Return

The input string, truncated to the desired number of bytes in UTF-8.

Parameters

desiredByteLength

The desired length, in UTF-8 bytes, of the output string.