Converting a Bitbuffer to storable string

With the implementations of bit buffers, they are extremely useful for data compression, and as such using them has a lot of pro’s for storing things such as large sets of data.

I’m actively writing a plugin in which will take spatial data and convert it to a bit buffer, which is working as intended. I then need to take this data and store it within something like a module script.

The issue occurs with the fact that ROBLOX standard string library does not like unicode characters which is what the buffer is reliant on.

Any ideas how you could store a buffer within a string- ideally while still keeping compression.

2 Likes

Note
Using the utf8 library doesn’t seem plausible because the buffer contains non-utf8 characters / unicode within it.

Can you store it in an attribute instead? I use that for saving and loading to buffers and it does work. Assuming your not manipulating the data and just throwing it straight into a buffer.

Storing it in an attribute does seem to retain the unicode information, and does work. However it has it’s own drawbacks such as attribute size limits, etc… Not sured if this will be an issue seeing as the limits are relatively large, however this does seem like a pretty “scuffed” work around.

1 Like

I am not really sure what problem do you have and what you want achieve.

I used buffer and to convert it into string I used buffer.string(buffer) and then buffer.fromstring(str) to turn it back to buffer.

Do you have any examples of data you storing in buffer and want to convert it into a string?

The issue isn’t converting the string from the buffer, it is taking this string and storing it within some sort of asset or container. Such as writing to a modulescript and storing the buffer contents as a string within that module.

This becomes challenging because the roblox string library doesn’t like non UTF characters, therefor throwing an error.

Thus far the only way I’ve managed to store it was from the suggestion above, which uses attributes. (Not entirely sure what the logic behind an attribute is, but it seemingly has support for all unicode)

I see, never had such task to deal with.

However it has it’s own drawbacks such as attribute size limits, etc…

You might use multiple attributes. I never ever reached attribute size limits so I may only expect that multiple attributes maybe used to store large data.