开源软件名称(OpenSource Name):iryont/lua-struct开源软件地址(OpenSource Url):https://github.com/iryont/lua-struct开源编程语言(OpenSource Language):Lua 100.0%开源软件介绍(OpenSource Introduction):lua-structImplementation of binary packing/unpacking in pure lua LuaRocks
what is it for?You can use it to pack and unpack binary data in pure lua. The idea is very similar to PHP unpack and pack functions. byte orderYou can use < or > at the beginning of the format string to specify the byte order. Default is little endian (<), but you can change it to big endian (>) as well. It is possible to dynamically change the byte order within the format string, so in general you can save types in different byte orders. available types
how to use it?local struct = require "struct"
local packed = struct.pack('<LIhBsbfd', 123456789123456789, 123456789, -3200, 255, 'Test message', -1, 1.56789, 1.56789)
local L, I, h, B, s, b, f, d = struct.unpack('<LIhBsbfd', packed)
print(L, I, h, B, s, b, f, d)
1.2345678912346e+017 123456789 -3200 255 Test message -1 1.5678899288177 1.56789 |
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论