Decompressing A Compressed String Isnt Working

I have a game with a level editor feature that allows users to save their tracks by copying a code. However, I encountered an issue when I created a large track. The code length exceeded the clipboard limit, preventing me from copying the entire code.

To solve this issue, I used the Compress extension to minimize the code length. While the compression worked successfully, I encountered a new problem when attempting to load the compressed code back into the game. The game would produce an error with no stack trace or error message, making it IMPOSSIBLE to identify and resolve the issue.

So, How can I load this compressed string without errors??

The compressing Implementation:

Decompressing Implementation:

Here is the compression result:

Here is the error:

Video:

Thanks!

Update:
I have further pinpointed the issue by creating a new project. There is still no difference.

Another video for the new project:

Update2: bump thread, no response for a while.

Since the compression extension just throws straight binary data into a string, and the data is not meant to be human readable, it might contain some data that, when interpreted as a string, are control flow characters, which might be ignored or reinterpreted by the browser or clipboard when storing text in the text field or copy-pasting it. Since information is lost this can cause a crash while decompressing the invalid data.

I’d recommend converting the string to base64 after conversion, as it represents the binary data using common characters. You just need to undo the base64 before decompressing to get back the original data.

Here’s an extension I created to do base64 conversions: Base64.json

3 Likes

Thank you for the helpful reply.
The extension you sent me isn’t available in the extension store, I know that I can install this JSON, but wouldn’t it be helpful if that was available in the extension store for others to use, also is there any other way to convert without this extension?
The extension author has included this video as a help guide, I’m not a music guy, so I don’t know what is this supposed to mean and how is this YouTuber related to Base64. I think it is a joke. I just don’t understand the point.
Anyway, thank you, @arthuro555!