Package-level declarations

Types

Link copied to clipboard

An immutable wrapper around a byte sequence providing String like functionality.

Link copied to clipboard
class ByteStringBuilder(initialCapacity: Int = 0)

A helper class facilitating ByteString construction.

Properties

Link copied to clipboard

Returns the range of valid byte indices for this byte string.

Functions

Link copied to clipboard
fun ByteStringBuilder.append(vararg bytes: Byte)

Appends bytes to this builder.

Appends unsigned byte to this builder.

Appends a byte string to this builder.

Link copied to clipboard

Returns a new read-only heap ByteBuffer wrapping this ByteString's content.

Link copied to clipboard
inline fun buildByteString(capacity: Int = 0, builderAction: ByteStringBuilder.() -> Unit): ByteString

Builds new byte string by populating newly created ByteStringBuilder initialized with the given capacity using provided builderAction and then converting it to ByteString.

Link copied to clipboard

fun ByteString(vararg bytes: Byte): ByteString
fun ByteString(vararg bytes: UByte): ByteString

Wraps given bytes into a byte string.

Link copied to clipboard

Returns true if the content of this byte string equals to the array.

Link copied to clipboard
fun Base64.decode(source: ByteString, startIndex: Int = 0, endIndex: Int = source.size): ByteArray

Decodes symbols from the specified source byte string or its subrange. Returns a ByteArray containing the resulting bytes.

Link copied to clipboard
fun Base64.decodeIntoByteArray(source: ByteString, destination: ByteArray, destinationOffset: Int = 0, startIndex: Int = 0, endIndex: Int = source.size): Int

Decodes symbols from the specified source byte string or its subrange and writes resulting bytes into the destination array. Returns the number of bytes written.

Link copied to clipboard
fun Base64.decodeToByteString(source: ByteArray, startIndex: Int = 0, endIndex: Int = source.size): ByteString
fun Base64.decodeToByteString(source: ByteString, startIndex: Int = 0, endIndex: Int = source.size): ByteString

Decodes symbols from the specified source byte string or its subrange. Returns a ByteString containing the resulting bytes.

fun Base64.decodeToByteString(source: CharSequence, startIndex: Int = 0, endIndex: Int = source.length): ByteString

Decodes symbols from the specified source char sequence or its substring. Returns a ByteString containing the resulting bytes.

Link copied to clipboard

Decodes content of a byte string into a string using UTF-8 encoding.

Decodes the content of a byte string to a string using given charset.

Link copied to clipboard
fun Base64.encode(source: ByteString, startIndex: Int = 0, endIndex: Int = source.size): String

Encodes bytes from the specified source byte string or its subrange. Returns a string with the resulting symbols.

Link copied to clipboard
fun Base64.encodeIntoByteArray(source: ByteString, destination: ByteArray, destinationOffset: Int = 0, startIndex: Int = 0, endIndex: Int = source.size): Int

Encodes bytes from the specified source byte string or its subrange and writes resulting symbols into the destination array. Returns the number of symbols written.

Link copied to clipboard
fun <A : Appendable> Base64.encodeToAppendable(source: ByteString, destination: A, startIndex: Int = 0, endIndex: Int = source.size): A

Encodes bytes from the specified source byte string or its subrange and appends resulting symbols to the destination appendable. Returns the destination appendable.

Link copied to clipboard
fun Base64.encodeToByteArray(source: ByteString, startIndex: Int = 0, endIndex: Int = source.size): ByteArray

Encodes bytes from the specified source byte string or its subrange. Returns a ByteArray containing the resulting symbols.

Link copied to clipboard

Encodes a string into a byte sequence using UTF8-encoding and wraps it into a byte string.

Encodes a string into a byte string using charset.

Link copied to clipboard

Returns true if this byte string ends with the suffix specified by the byteArray.

Returns true if this byte string ends with the suffix specified by the byteString.

Link copied to clipboard
fun ByteBuffer.getByteString(length: Int = remaining()): ByteString

Reads length bytes of data from this ByteBuffer starting from the current position and wraps them into a new ByteString.

Reads length bytes of data from this ByteBuffer starting from at index and wraps them into a new ByteString.

Link copied to clipboard

Parses bytes from this string using the specified HexFormat.

Link copied to clipboard
fun ByteString.indexOf(byte: Byte, startIndex: Int = 0): Int

Returns the index within this byte string of the first occurrence of the specified byte, starting from the specified startIndex. If the byte not found, -1 is returned.

fun ByteString.indexOf(byteArray: ByteArray, startIndex: Int = 0): Int

Returns the index within this byte string of the first occurrence of the specified byteArray, starting from the specified startIndex. If the byteArray not found, -1 is returned.

fun ByteString.indexOf(byteString: ByteString, startIndex: Int = 0): Int

Returns the index within this byte string of the first occurrence of the specified byteString, starting from the specified startIndex. If the byteString not found, -1 is returned.

Link copied to clipboard

Returns true if this byte string is empty.

Link copied to clipboard

Returns true if this byte string is not empty.

Link copied to clipboard
fun ByteString.lastIndexOf(byte: Byte, startIndex: Int = 0): Int

Returns the index within this char sequence of the last occurrence of the specified byte, starting from the specified startIndex. If the byte not found, -1 is returned.

fun ByteString.lastIndexOf(byteArray: ByteArray, startIndex: Int = 0): Int

Returns the index within this char sequence of the last occurrence of the specified byteArray, starting from the specified startIndex. If the byteArray not found, -1 is returned.

fun ByteString.lastIndexOf(byteString: ByteString, startIndex: Int = 0): Int

Returns the index within this char sequence of the last occurrence of the specified byteString, starting from the specified startIndex. If the byteString not found, -1 is returned.

Link copied to clipboard

Writes string into this ByteBuffer starting from the current position.

Writes string into this ByteBuffer starting from position at.

Link copied to clipboard

Returns true if this byte string starts with the prefix specified by the byteArray.

Returns true if this byte string starts with the prefix specified by the byteString.

Link copied to clipboard
fun <Error class: unknown class>.toByteString(): ByteString

Returns a new ByteString holding data copied from this NSData.

Link copied to clipboard
fun ByteString.toHexString(format: HexFormat = HexFormat.Default): String

Formats bytes in this byte string using the specified format.

fun ByteString.toHexString(startIndex: Int = 0, endIndex: Int = size, format: HexFormat = HexFormat.Default): String

Formats bytes in this byte string using the specified HexFormat.

Link copied to clipboard
fun ByteString.toNSData(): <Error class: unknown class>

Returns a new NSData instance initialized with bytes copied from this ByteString.