Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature request: set endianess at library level #1367

Open
elect86 opened this issue Oct 17, 2023 · 3 comments
Open

Feature request: set endianess at library level #1367

elect86 opened this issue Oct 17, 2023 · 3 comments

Comments

@elect86
Copy link

elect86 commented Oct 17, 2023

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

@swankjesse
Copy link
Member

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.

@elect86
Copy link
Author

elect86 commented Oct 18, 2023

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

@swankjesse
Copy link
Member

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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants