Package-level declarations

Types

Link copied to clipboard

Builds a ByteArray from primary types

Link copied to clipboard

Byte order used for encoding and decoding primary types into a ByteArray

Link copied to clipboard
object CKSUM : CRC
Link copied to clipboard
interface CRC

A Cyclic Redundancy Check (CRC)

Link copied to clipboard
object CRC10 : CRC
Link copied to clipboard
object CRC11 : CRC
Link copied to clipboard
object CRC12
Link copied to clipboard
object CRC13
Link copied to clipboard
object CRC14
Link copied to clipboard
object CRC15 : CRC
Link copied to clipboard
object CRC16 : CRC
Link copied to clipboard
object CRC17
Link copied to clipboard
object CRC21
Link copied to clipboard
object CRC24 : CRC
Link copied to clipboard
object CRC3
Link copied to clipboard
object CRC30
Link copied to clipboard
object CRC31
Link copied to clipboard
object CRC32 : CRC
Link copied to clipboard
object CRC4
Link copied to clipboard
object CRC40
Link copied to clipboard
object CRC5
Link copied to clipboard
object CRC6
Link copied to clipboard
object CRC64 : CRC
Link copied to clipboard
object CRC7 : CRC
Link copied to clipboard
object CRC8 : CRC
Link copied to clipboard
object CRCA : CRC
Link copied to clipboard
object CRCB : CRC
Link copied to clipboard

Character encoding

Link copied to clipboard
object JAMCRC : CRC
Link copied to clipboard

Exception thrown when a character cannot be encoded into UTF-8

Link copied to clipboard
data class StringEncodingSettings(val endMarking: StringEncodingSettings.EndMarking = LengthPrefix.ByteLength, val encoding: Encoding = Encoding.UTF_8)

Settings to determine how a String should be encoded into a ByteArray.

Properties

Link copied to clipboard

Returns the number of Bytes required to encode a String using ASCII.

Link copied to clipboard

Returns the number of Bytes required to encode a String using UTF-16.

Link copied to clipboard

Returns the number of Bytes required to encode a String using UTF-8.

Functions

Link copied to clipboard
infix fun Int24.and(other: Int24): Int24

Performs a bitwise AND operation between the two values.

infix fun UInt24.and(other: UInt24): UInt24
Link copied to clipboard
fun buildByteArray(order: ByteOrder = ByteOrder.LEAST_SIGNIFICANT_FIRST, expectedSize: Int = Long.SIZE_BYTES, block: ByteArrayBuilder.() -> Unit): ByteArray

Builds a ByteArray using a ByteArrayBuilder

Link copied to clipboard

Returns the number of Bytes required to encode a String using the given StringEncodingSettings.

Link copied to clipboard

Returns the number of Bytes required to encode a String using the given Encoding.

Link copied to clipboard
fun String.copyAsciiIntoArray(array: ByteArray, offset: Int = 0, byteOrder: ByteOrder): ByteArray
Link copied to clipboard
fun Encoding.copyCharIntoByteArray(char: Char, array: ByteArray, offset: Int = 0, byteOrder: ByteOrder): ByteArray

Encodes a Char using the given Encoding and ByteOrder and copies it into a ByteArray at a given offset.

Link copied to clipboard
fun Encoding.copyEncodedStringIntoArray(string: String, array: ByteArray, offset: Int = 0, byteOrder: ByteOrder): ByteArray

Encodes a String using the given Encoding and ByteOrder and copies it into a ByteArray at a given offset.

Link copied to clipboard
fun String.copyIntoArray(array: ByteArray, settings: StringEncodingSettings, offset: Int = 0, order: ByteOrder): ByteArray

Encodes a String using the given StringEncodingSettings and ByteOrder and copies it into a ByteArray

Link copied to clipboard

Encodes this MedFloat16 and copies it into a ByteArray at a given offset.

Encodes this MedFloat32 and copies it into a ByteArray at a given offset.

fun Int24.copyIntoByteArray(array: ByteArray, offset: Int = 0, byteOrder: ByteOrder): ByteArray

Encodes this Int24 and copies it into a ByteArray at a given offset.

fun UInt24.copyIntoByteArray(array: ByteArray, offset: Int = 0, byteOrder: ByteOrder): ByteArray

Encodes this UInt24 and copies it into a ByteArray at a given offset.

fun Double.copyIntoByteArray(array: ByteArray, offset: Int = 0, byteOrder: ByteOrder): ByteArray

Encodes this Double and copies it into a ByteArray at a given offset.

fun Float.copyIntoByteArray(array: ByteArray, offset: Int = 0, byteOrder: ByteOrder): ByteArray

Encodes this Float and copies it into a ByteArray at a given offset.

fun Int.copyIntoByteArray(array: ByteArray, offset: Int = 0, byteOrder: ByteOrder): ByteArray

Encodes this Int and copies it into a ByteArray at a given offset.

fun Long.copyIntoByteArray(array: ByteArray, offset: Int = 0, byteOrder: ByteOrder): ByteArray

Encodes this Long and copies it into a ByteArray at a given offset.

fun Short.copyIntoByteArray(array: ByteArray, offset: Int = 0, byteOrder: ByteOrder): ByteArray

Encodes this Short and copies it into a ByteArray at a given offset.

fun UInt.copyIntoByteArray(array: ByteArray, offset: Int = 0, byteOrder: ByteOrder): ByteArray

Encodes this UInt and copies it into a ByteArray at a given offset.

fun ULong.copyIntoByteArray(array: ByteArray, offset: Int = 0, byteOrder: ByteOrder): ByteArray

Encodes this ULong and copies it into a ByteArray at a given offset.

fun UShort.copyIntoByteArray(array: ByteArray, offset: Int = 0, byteOrder: ByteOrder): ByteArray

Encodes this UShort and copies it into a ByteArray at a given offset.

Link copied to clipboard
fun String.copyUTF16IntoArray(array: ByteArray, offset: Int = 0, byteOrder: ByteOrder): ByteArray

Encodes a String using UTF-16 and copies it into a ByteArray at a given offset.

Link copied to clipboard
fun Char.copyUTF16IntoByteArray(array: ByteArray, offset: Int = 0, byteOrder: ByteOrder): ByteArray

Encodes a Char and copies it into a ByteArray at a given offset in UTF-16 using the given ByteOrder.

Link copied to clipboard
fun String.copyUTF8IntoArray(array: ByteArray, offset: Int = 0, byteOrder: ByteOrder, throwOnMalformed: Boolean = false): ByteArray

Encodes a String using UTF-8 and copies it into a ByteArray at a given offset.

Link copied to clipboard

Decodes a Char from a Byte assuming ASCII encoding.

fun ByteArray.decodeAsciiChar(octetIndex: Int): Char

Decodes a Char at octetIndex from a ByteArray assuming ASCII encoding.

Link copied to clipboard
fun ByteArray.decodeDouble(octetIndex: Int, byteOrder: ByteOrder): Double

Converts ByteArray to Double

Link copied to clipboard
fun ByteArray.decodeFloat(octetIndex: Int, byteOrder: ByteOrder): Float

Converts ByteArray to Float

Link copied to clipboard
fun ByteArray.decodeInt(octetIndex: Int, byteOrder: ByteOrder): Int

Converts ByteArray to Int

Link copied to clipboard
fun ByteArray.decodeInt24(octetIndex: Int, byteOrder: ByteOrder): Int24

Decodes a ByteArray into an Int24 using the 3 bytes starting from octetIndex

Link copied to clipboard
fun ByteArray.decodeLong(octetIndex: Int, byteOrder: ByteOrder): Long

Converts ByteArray to Long

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
fun ByteArray.decodeShort(octetIndex: Int, byteOrder: ByteOrder): Short

Converts ByteArray to Short

Link copied to clipboard

Decodes a Sequence of Byte ordered Least Significant first into a String using StringEncodingSettings

Decodes a ByteArray ordered Least Significant first into a String using StringEncodingSettings

Link copied to clipboard
fun ByteArray.decodeUByte(octetIndex: Int): UByte

Decodes a UByte from the given ByteArray at the given octetIndex.

Link copied to clipboard
fun ByteArray.decodeUInt(octetIndex: Int, byteOrder: ByteOrder): UInt

Converts ByteArray to UInt

Link copied to clipboard
fun ByteArray.decodeUInt24(octetIndex: Int, byteOrder: ByteOrder): UInt24

Decodes a ByteArray into an UInt24 using the 3 bytes starting from octetIndex

Link copied to clipboard
fun ByteArray.decodeULong(octetIndex: Int, byteOrder: ByteOrder): ULong

Converts ByteArray to ULong

Link copied to clipboard
fun ByteArray.decodeUShort(octetIndex: Int, byteOrder: ByteOrder): UShort

Converts ByteArray to UShort

Link copied to clipboard
fun ByteArray.decodeUTF16Char(octetIndex: Int, order: ByteOrder): Char

Decodes a Char at octetIndex from a ByteArray assuming UTF-16 encoding.

Link copied to clipboard

Decodes a Char from a Byte assuming UTF-8 encoding.

fun ByteArray.decodeUTF8Char(octetIndex: Int): Char

Decodes a Char at octetIndex from a ByteArray assuming UTF-8 encoding.

Link copied to clipboard
fun Encoding.encodeChar(char: Char, byteOrder: ByteOrder): ByteArray

Encodes a Char into a ByteArray using the given Encoding and ByteOrder.

Link copied to clipboard
fun Encoding.encodeString(string: String, byteOrder: ByteOrder): ByteArray

Encodes a String into a ByteArray using the given Encoding and ByteOrder.

Link copied to clipboard

Checks whether the bit at index is set in this Int24

Checks whether the bit at index is set in this UInt24

Checks whether the bit at index is set in this Byte

Checks whether the bit at index is set in this ByteArray

fun Int.isBitSet(index: Number): Boolean

Checks whether the bit at index is set in this Int

Checks whether the bit at index is set in this Long

Checks whether the bit at index is set in this Short

Checks whether the bit at index is set in this UByte

Checks whether the bit at index is set in this UInt

Checks whether the bit at index is set in this ULong

Checks whether the bit at index is set in this UShort

Link copied to clipboard
fun Int.length(): Int

Determines the number of digits in an Integer

Link copied to clipboard
infix fun Int24.or(other: Int24): Int24

Performs a bitwise OR operation between the two values.

infix fun UInt24.or(other: UInt24): UInt24
Link copied to clipboard
fun Int24.setBit(index: Number): Int24

Creates a Int24 that is equal to this Int24 except the bit at index is set

fun UInt24.setBit(index: Number): UInt24

Creates a UInt24 that is equal to this UInt24 except the bit at index is set

fun Byte.setBit(index: Number): Byte

Creates a Byte that is equal to this Byte except the bit at index is set

Creates a ByteArray that is equal to this array except the bit at index is set

fun Int.setBit(index: Number): Int

Creates a Int that is equal to this Int except the bit at index is set

fun Long.setBit(index: Number): Long

Creates a Long that is equal to this Long except the bit at index is set

fun Short.setBit(index: Number): Short

Creates a Short that is equal to this Short except the bit at index is set

fun UByte.setBit(index: Number): UByte

Creates a UByte that is equal to this UByte except the bit at index is set

fun UInt.setBit(index: Number): UInt

Creates a UInt that is equal to this UInt except the bit at index is set

fun ULong.setBit(index: Number): ULong

Creates a ULong that is equal to this ULong except the bit at index is set

fun UShort.setBit(index: Number): UShort

Creates a UShort that is equal to this UShort except the bit at index is set

Link copied to clipboard
infix fun Int24.shl(bitCount: Int): Int24
infix fun Byte.shl(bitCount: Int): Byte
infix fun Short.shl(bitCount: Int): Short
infix fun UByte.shl(bitCount: Int): UByte
infix fun UShort.shl(bitCount: Int): UShort

Shifts this value left by the bitCount number of bits.

infix fun UInt24.shl(bitCount: Int): UInt24
Link copied to clipboard
infix fun Int24.shr(bitCount: Int): Int24
infix fun Byte.shr(bitCount: Int): Byte
infix fun Short.shr(bitCount: Int): Short
infix fun UByte.shr(bitCount: Int): UByte
infix fun UShort.shr(bitCount: Int): UShort

Shifts this value right by the bitCount number of bits.

infix fun UInt24.shr(bitCount: Int): UInt24
Link copied to clipboard

Encodes a Char to a Byte in ASCII.

Encodes a String to a ByteArray using ASCII.

Link copied to clipboard

Encodes a Char to a Byte in ASCII or null if the character cannot be represented in ASCII.

Encodes a String to a ByteArray using ASCII or null if the string contains a non-ASCII character.

Link copied to clipboard

Encodes this MedFloat16 into a ByteArray.

Encodes this MedFloat32 into a ByteArray.

Encodes this UByte into a ByteArray.

Encodes this Int24 into a ByteArray.

Encodes this UInt24 into a ByteArray.

Encodes a Double into a ByteArray

Encodes a Float into a ByteArray

Encodes this Int into a ByteArray.

Encodes this Long into a ByteArray.

Encodes this Short into a ByteArray.

Encodes this UInt into a ByteArray.

Encodes this ULong into a ByteArray.

Encodes a String to a ByteArray using the given StringEncodingSettings and ByteOrder.

Link copied to clipboard
fun Char.toUTF16(byteOrder: ByteOrder): ByteArray

Encodes a Char to a ByteArray in UTF-16 using the given ByteOrder.

Encodes a String to a ByteArray using UTF-16.

Link copied to clipboard
fun String.toUTF8(byteOrder: ByteOrder, throwOnMalformed: Boolean = false): ByteArray

Encodes a String to a ByteArray using UTF-8.

Link copied to clipboard
fun String.utf8Size(throwOnMalformed: Boolean): Int

Returns the number of Bytes required to encode a String using UTF-8.