We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
struct.calcsize
For a string like BBBBBBBh, jspack and Python give different sizes:
BBBBBBBh
FMT="BBBBBBBh" $ node -e "console.log(require('jspack').jspack.CalcLength('$FMT'))" 9 $ python -c "import struct; print(struct.calcsize('$FMT'))" 10
The text was updated successfully, but these errors were encountered:
This is expected behavior.
Per the readme:
Character | Byte Order ---------------------------------- < | little-endian > | big-endian ! | network (= big-endian)
If the first character is not one of these, "!" is assumed.
This is different than Python's default choice
If the first character is not one of these, '@' is assumed.
The difference between these is that '@' is native byte order. System dependent. And it's not supported by jspack. The python docs also say
Padding is only automatically added between successive structure members. No padding is added at the beginning or the end of the encoded struct.
Padding i being added for the h because it sites at byte 7. When using the native format, Python wants to put the short at byte 8.
h
>>> struct.calcsize('BBBBBBBh') 10 >>> struct.calcsize('<BBBBBBBh') 9 >>> struct.calcsize('!BBBBBBBh') 9
Sorry, something went wrong.
No branches or pull requests
For a string like
BBBBBBBh
, jspack and Python give different sizes:The text was updated successfully, but these errors were encountered: