Open MartinDevi opened 5 years ago
You should avoid situations that require streaming base64. The ByteString encoder/decoder should be enough for most use cases.
That said, I'd love to see a gist that does this. In those awkward cases where you have a lot of base64 this could be handy.
If only I had the luxury of choosing the format of the data that I receive 😄
I gave it a shot for the Base64Decoder
. I would've preferred to have this within the Okio library itself though, rather than having to copy the Base64 decoder into my own project.
All that's needed is some specific Base64 methods which don't perform string allocations. Should be fairly easy to add.
fun CharArray.decodeBase64(target: ByteArray, offset: Int, length: Int)
fun CharArray.decodeBase64(target: Buffer, offset: Int, length: Int)
Has this feature been considered before? I'd happily put some time in to work on it.
In the suggestion above, I use the
Reader
/Writer
classes because since Base64 uses text characters it seems to make more sense.