Add proper binary string data support for DataStores and MessagingService

string.pack is a great addition to the API, but we still can’t use these packed strings for DataStore saves and MessagingService messages without expensive base64 / ascii85 conversions. MessagingService only allows 1KB for messages, so it would be very practical to use compact fixed-length binary formats. It would be extremely helpful to be able to utilize all 0-255 bytes for both of these APIs.


I’m hoping to switch to using binary strings for save data someday (instead of bit buffers), so that I can efficiently skip through data and find specific information without needing to deserialize the entire thing. If I need to redirect them to another server, I could just skip to their active character’s data, read its current zone, and send them on their way. Players can have potentially hundreds of individual characters with stats, items, quest progress, perks, etc., so deserializing between intermediate formats can take milliseconds of execution time from an already busy server. With a packed string format it’s very fast.

I’m also planning a house system with furniture customization, and string.pack is the obvious solution for storing these objects. “{X:-61.20931480293841,Y:-13.1213440189129,Z:21.10298308140293}” has horrible efficiency compared to string.pack("fff", x, y, z) which uses only 12 bytes. Compact formats like this will reduce network overheads, reduce server overheads, and reduce data storage costs. It should be supported properly.

original reply


I have posted about this extensively over the years and others have had problems related to invalid bytes and character combinations.

Release Notes for 441 - #25 by Tomarty
Port string.pack and string.unpack from Lua 5.3 to RBX.Lua - #2 by Tomarty
https://devforum.roblox.com/t/what-characters-are-allowed-in-datastores/26461
DataStore wont accept "<" or bytes 128-255

23 Likes

It may be difficult to get all 255 bytes because of 0 being a weird byte in Lua strings but please yes.

1 Like

Lua supports 0 like any other character. string.pack wouldn’t work without it. It’s really convenient for storing data.