antirez / lua-cmsgpack

A self contained Lua MessagePack C implementation.
355 stars 118 forks source link

Support for treating strings as binary #34

Open thedrow opened 9 years ago

thedrow commented 9 years ago

msgpack 2.0 has the ability to treat strings as binary. http://fperrad.github.io/lua-MessagePack/msgpack.html (see the set_string method) Unfortunately this is not supported with this library. When serializing strings as binary I get the following error from redis: Bad data format in input What can I do to help resolve this issue?

muzuiget commented 7 years ago

It look like author drop support this project, I fork it to fix myself. Here is my path https://github.com/muzuiget/lua-cmsgpack/commit/f45b9e6bdbb9890d6799518a58522be242d01b25

I lazy to read the msgpack spec, but read the another lua msgpack library https://github.com/fperrad/lua-MessagePack source code, which I use before in my project. It has option let you to choose treat Lua string as what msgpack type is.

The key code is here https://github.com/fperrad/lua-MessagePack/blob/master/src5.3/MessagePack.lua#L76,L116 It look like just need to change the flag bytes. I test on my project it work fine.