What I have tried so far is replacing special characters with an identifying phrase with it’s byte value attached, and it seems to be successful. But in the screenshot above there are no special characters present so I am unsure what is causing it to become malformed. (However, the “�” character seems to not be replaced)
function replaceSpecialChar(checkChar)
local checkByte = string.byte(checkChar)
local specials = {'\\', '$', '^', '*', '(', '%)', '.', '%[', '%]', '+', '-', '?', '"', "%%", "�"}
for _, char in specials do
local byte = string.byte(char)
if checkByte == byte then
return checkByte..";prefixGSUBBEDbyte"
end
end
return checkChar
end
Final note:
Every few encryptions will come out fine:
The problem here is that the “�” symbol is the same symbol as the one before and after it, so if it were the problem it would be cutoff earlier or later, It’s also the same one used in the photo where the string is seemingly fine. I have confirmed this by using string.byte and all of them coming up byte 239
I assumed this was the problem anyways and tried using string.gsub to replace it and for some reason it just doesn’t want to be detected by gsub. Any idea why?
That’s not true, this is a placeholder symbol for when the script editor doesn’t know how to represent the character. So two symbols can look the same because they’re unrecognizable, but still not be equal.
Also if whatever you’re trying to encrypt isn’t large(such as simple text or an image), you can just represent it using a safer encoding, such as base64(if I’m not mistaken base64 will increase the string length by 33.3%).
I have checked each of these byte values and all of them are 239
And for some reason it still gets cut off.
I have explored alternative ways of having the character encoded but I really like how these symbols look lmao. I understand the easy solution is to switch to the alternative and I might just do that now, but I still need to understand and learn why these characters are always causing the string to become malformed. Also that byte 239 character will not be detected by gsub for some reason.
To add, it isn’t just this character, but multiple