okio icon indicating copy to clipboard operation
okio copied to clipboard

Feature request: set endianess at library level

Open elect86 opened this issue 2 years ago • 3 comments

As titled, I'd like an option as Buffer::order where I can set the endianess at the library level

elect86 avatar Oct 17 '23 15:10 elect86

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.

swankjesse avatar Oct 18 '23 03:10 swankjesse

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

elect86 avatar Oct 18 '23 07:10 elect86

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!

swankjesse avatar Oct 18 '23 12:10 swankjesse