okio
okio copied to clipboard
Feature request: set endianess at library level
As titled, I'd like an option as Buffer::order where I can set the endianess at the library level
You can use readIntLe/writeIntLe etc. if you want little-endian ints. And you can write your own abstraction to toggle between endianness if that’s really what you need.
Could you say more about your use case? It’s been my experience that usually endianness doesn’t vary at the callsite.
And you can write your own abstraction to toggle between endianness if that’s really what you need.
that's what I'm doing right now
I'm simply reading/parsing a binary file (SDT format) and I have to use little endian
I thought something in the library itself could be beneficial for other users as well
The way it works in java.nio.Buffer is annoying because it puts state on the Buffer instance.
We saw bugs around helper methods that flipped the endianness but didn’t put it back, and those bugs are difficult to debug if they’re sometimes safe when the initial endianness is what they’re changing it to.
Calling readIntLe is stateless!