getUBytes

Returns a UByteArray containing the target value.

Return

An array of containing the target byte.


fun Byte.getUBytes(buffer: UByteArray, offset: Int = 0): Int
fun UByte.getUBytes(buffer: UByteArray, offset: Int = 0): Int

Fills the given buffer, starting from the given offset, with the target value.

If the given array's size is less than offset + 1, an exception will be thrown.

Return

1, the number of bytes written to the buffer.

Parameters

buffer

UByteArray that will be filled with the target byte.

offset

Offset position in the buffer array to start writing at.

Default: 0


fun Int.getUBytes(be: Boolean = true): UByteArray

Returns a UByteArray containing the 4 unsigned bytes that make up the target Int value.

Return

An array of 4 unsigned bytes.

Parameters

be

Whether the bytes should be in Big Endian order.

Default: true


fun Int.getUBytes(buffer: UByteArray, offset: Int = 0, be: Boolean = true): Int

Fills the given buffer, starting from the given offset, with the 4 bytes that make up the target Int value.

If the given array's size is less than offset + 4, an exception will be thrown.

Return

4, the number of bytes written to the buffer.

Parameters

buffer

UByteArray that will be filled with the bytes from the target Int.

offset

Offset position in the buffer array to start writing at.

Default: 0

be

Whether the bytes should be written in Big Endian order.

Default: true


fun Long.getUBytes(be: Boolean = true): UByteArray

Returns a UByteArray containing the 8 unsigned bytes that make up the target Long value.

Return

An array of 8 unsigned bytes.

Parameters

be

Whether the bytes should be in Big Endian order.

Default: true


fun Long.getUBytes(buffer: UByteArray, offset: Int = 0, be: Boolean = true): Int

Fills the given buffer, starting from the given offset, with the 8 bytes that make up the target Long value.

If the given array's size is less than offset + 8, an exception will be thrown.

Return

8, the number of bytes written to the buffer.

Parameters

buffer

UByteArray that will be filled with the bytes from the target Long.

offset

Offset position in the buffer array to start writing at.

Default: 0

be

Whether the bytes should be written in Big Endian order.

Default: true


Returns a UByteArray containing the 2 unsigned bytes that make up the target Short value.

Return

An array of 2 unsigned bytes.

Parameters

be

Whether the bytes should be in Big Endian order.

Default: true


fun Short.getUBytes(buffer: UByteArray, offset: Int = 0, be: Boolean = true): Int

Fills the given buffer, starting from the given offset, with the 2 bytes that make up the target Short value.

If the given array's size is less than offset + 2, an exception will be thrown.

Return

2, the number of bytes written to the buffer.

Parameters

buffer

UByteArray that will be filled with the bytes from the target Short.

offset

Offset position in the buffer array to start writing at.

Default: 0

be

Whether the bytes should be written in Big Endian order.

Default: true


fun UInt.getUBytes(be: Boolean = true): UByteArray

Returns a UByteArray containing the 4 unsigned bytes that make up the target UInt value.

Return

An array of 4 unsigned bytes.

Parameters

be

Whether the bytes should be in Big Endian order.

Default: true


fun UInt.getUBytes(buffer: UByteArray, offset: Int = 0, be: Boolean = true): Int

Fills the given buffer, starting from the given offset, with the 4 bytes that make up the target UInt value.

If the given array's size is less than offset + 4, an exception will be thrown.

Return

4, the number of bytes written to the buffer.

Parameters

buffer

UByteArray that will be filled with the bytes from the target UInt.

offset

Offset position in the buffer array to start writing at.

Default: 0

be

Whether the bytes should be written in Big Endian order.

Default: true


Returns a UByteArray containing the 8 unsigned bytes that make up the target ULong value.

Return

An array of 8 unsigned bytes.

Parameters

be

Whether the bytes should be in Big Endian order.

Default: true


fun ULong.getUBytes(buffer: UByteArray, offset: Int = 0, be: Boolean = true): Int

Fills the given buffer, starting from the given offset, with the 8 bytes that make up the target ULong value.

If the given array's size is less than offset + 8, an exception will be thrown.

Return

8, the number of bytes written to the buffer.

Parameters

buffer

UByteArray that will be filled with the bytes from the target ULong.

offset

Offset position in the buffer array to start writing at.

Default: 0

be

Whether the bytes should be written in Big Endian order.

Default: true


Returns a UByteArray containing the 2 unsigned bytes that make up the target UShort value.

Return

An array of 2 unsigned bytes.

Parameters

be

Whether the bytes should be in Big Endian order.

Default: true


fun UShort.getUBytes(buffer: UByteArray, offset: Int = 0, be: Boolean = true): Int

Fills the given buffer, starting from the given offset, with the 2 bytes that make up the target UShort value.

If the given array's size is less than offset + 2, an exception will be thrown.

Return

2, the number of bytes written to the buffer.

Parameters

buffer

UByteArray that will be filled with the bytes from the target UShort.

offset

Offset position in the buffer array to start writing at.

Default: 0

be

Whether the bytes should be written in Big Endian order.

Default: true