PDA

View Full Version : binary stream locale and encoding


brekehan
05-04-2009, 02:43 PM
I don’t see any information on the locale and encoding of strings, integral types, or floats for the binary stream operations in the documentation.

“as string”
“4 byte integer”
“4 byte float”
None of these tell very much about how to read the binary back again.

All characters are ASCII?
Byte size is 8?
Bit order is little indian?
My biggest problem is signed numbers - Two-complement, One-complement, sign+magnitude, BCD, etc?
How are we storing floats?

What is used?

I’ve got to write a corresponding C++ parser for the data written out by maxscript.

code like:

D3DXCOLOR ambientColor
file.read(reinterpret_cast<char *>(&ambientColor.r), 4);
file.read(reinterpret_cast<char *>(&ambientColor.g), 4);
file.read(reinterpret_cast<char *>(&ambientColor.b, 4);
file.read(reinterpret_cast<char *>(&ambientColor.a), 4);


Is not satisfactory, as a user may change encoding and locale of client programs that use my library and break the parser. I need to explicitly handle the encoding of each type, reading byte by byte, assembling strings, integers, and floats from the data, then transforming to the local encoding.

CGTalk Moderation
05-04-2009, 02:43 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.