textPreview

fun textPreview(bytes: ByteArray, contentType: String?, maxLength: Long, byteCount: Long = bytes.size.toLong()): BodyPreview

Text preview of bytes, decoded with the charset the message declared — a Latin-1 response used to come out of the store full of replacement characters.

UTF-8 (and no charset at all, the sane default) keeps the fast path with its multi-byte-safe cut. Anything else goes through Ktor's decoder, which offers no equivalent notion of a safe boundary, so those previews are cut on the byte. A charset name the platform can't honour — Kotlin/Native supports only a handful — falls back to UTF-8 rather than losing the body.

byteCount is the size of the whole body, which may exceed bytes when the caller only kept a prefix; it is what the viewer reports next to a truncation notice.