In .NET for instance, a method like `byte[] BitCon...
# multiplatform
s
In .NET for instance, a method like
byte[] BitConverter.GetBytes(Int32)
will preserve the computer architecture byte order (big-endian or little-endian). Is there some equivalent (keeping the proper byte order) to this method in Kotlin? NOTE: It is to be used in a Kotlin multiplatform context.
k
ByteArray.setIntAt(index: Int, value: Int)
s
I don't see this method in class
ByteArray
. Is it an extension method available for native only?
k
yes
b
When cross-posting please forward the original message rather than copying it. this way the discussions can be focused on the same thread.
s
Ok, I deleted the other one. Is "Share message..." the proper way to forward to another channel?
b
Yep
k
there doesn't seem to be a common way to handle this, unfortunately
it looks like on uses ByteBuffer for Kotlin/JVM
s
Well, I guess that as long as all operations that are "endianness dependent" are not "abstracted up" in the common layer, we'll have to do it ourselves. ☹️
@Kris Wong Is
setIntAt
available for
UByteArray
as well or only
ByteArray
?
Well, it doesn't seem available for
UByteArray
, so I'll use
ByteArray
and convert at the end.
k
correct