I’m developing a simple protocol that is used to read/write integer values from/to a buffer. The vast majority of integers are below 128, but much larger values are possible, so I’m looking at some form of multi-byte encoding to store the values in a concise way.
What is the simplest and fastest way to read/write multi-byte values in a platform-independent (i.e. byte order agnostic) way?
XDR format might help you there. If I had to summarize it in one sentence, it’s a kind of binary UTF-8 for integers.
Edit: As mentioned in my comment below, I “know” XDR because I use several XDR-related functions in my office job. Only after your comment I realized that the “packed XDR” format I use every day isn’t even part of the official XDR docs, so I’ll describe it seperately.
The idea is thus:
I have no idea if this is a “real” format or my (former) coworker created this one himself (which is why I don’t post code).