05nelsonm / encoding

A Kotlin Multiplatform library for configurable, streamable, efficient and extensible Encoding/Decoding with support for base16/32/64.
Apache License 2.0
33 stars 5 forks source link

Add support for partial array encoding #107

Closed 05nelsonm closed 1 year ago

05nelsonm commented 1 year ago

Would be nice to be able to specify an offset and length when encoding

@Throws(IllegalArgumentException::class, IndexOutOfBoundsException::class)
fun ByteArray.encodeToString(offset: Int, len: Int, encoder: Encoder<*>): String {
    // ...
}

Usage

val bytes = Random.Default.nextBytes(500)
val partialEncoding = bytes.encodeToString(50, 100, Base16())
05nelsonm commented 1 year ago

If users desire this, they can utilize Encoder.newEncoderFeed