Dekkonot / bitbuffer

A binary stream module for packing binary data in pure Lua
https://dekkonot.github.io/bitbuffer/
MIT License
44 stars 11 forks source link

Read base64 string buffer #30

Closed jeparlefrancais closed 3 years ago

jeparlefrancais commented 3 years ago

This request comes from the fact that I can't seem to assign the value I get from buffer.dumpString() into a StringValue object Value property. I tried using a ModuleScript's Source property to store the string but didn't have any luck with that neither.

My solution for this is to store the dumpBase64() string, but it would be nicer to have a way to make BitBuffer read it back 🙂

It could be done by changing the API to something like this:

BitBuffer(stream: str, options?: { format = "byte" | "base64" | "binary" | "hex" })

Let me know what you think about that!

Dekkonot commented 3 years ago

This request comes from the fact that I can't seem to assign the value I get from buffer.dumpString() into a StringValue object Value property. I tried using a ModuleScript's Source property to store the string but didn't have any luck with that neither. That's because Roblox's string properties are all null-terminated. I don't know why; it's annoying.

I'm not sure about introducing a second argument on the constructor if it's only used for specifying the stream format. Would a writeBase64 function work for you instead?

jeparlefrancais commented 3 years ago

Yeah that would work too! I already have written a decoder so that I would not be blocked, do you want me to submit a PR? If yes feel free to just ping me on discord 😄