copyIntoArray

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

Return

The encoded ByteArray

Parameters

array

the ByteArray to copy the encoded data into.

offset

the offset at which to copy the encoded data.

order

the ByteOrder to use. When passing ByteOrder.MOST_SIGNIFICANT_FIRST the first character will be at the end of the array.

Throws

if the string contains a null character and StringEncodingSettings.NullTerminated is used, or if the length of the string cannot be encoded by StringEncodingSettings.LengthPrefix