toString

open override fun toString(): String(source)

Returns a string representation of this byte string. A string representation consists of size and a hexadecimal-encoded string of a byte sequence wrapped by this byte string.

The string representation has the following format ByteString(size=3 hex=ABCDEF), for empty strings it's always ByteString(size=0).

Note that a string representation includes the whole byte string content encoded. Due to limitations exposed for the maximum string length, an attempt to return a string representation of too long byte string may fail.

Samples

import kotlinx.io.bytestring.*
import kotlin.test.*

fun main() { 
   //sampleStart 
   assertEquals("ByteString(size=0)", ByteString().toString())
assertEquals("ByteString(size=3 hex=000102)", ByteString(0, 1, 2).toString()) 
   //sampleEnd
}