How would I convert a string to Unicode Characters?

How should I go about converting a string to Unicode Characters / Hexadecimal Characters (e.g. “\000\000\000”).

I know it probably has to do with gsub, at the least.

I’m just using this for a simple script, but haven’t found anything online about it.

Help would be greatly appreciated.

1 Like

string.char() apparently does it? This only works on single characters.

If you’re looking for whole strings, go for string.byte().

Read documentation when necessary.

Byte works? How would I implement this into a function, or should I just check the documentation.

I also read that there is \x (hexadecimal),\u (unicode), and \z (escaped)

You should read into it: string | Roblox Creator Documentation

In this case, use string.byte(string)(other parameters only for focusing parts of the strings). I’m not entirely sure what the bytes translate to but maybe it’s the standard ASCII.

I just tried this out,

print(string.byte("test test2"))

prints “116” which I don’t really understand, OH and another question, how would I decode this bytecode.

That only works on one letter at a time. 116 is the decimal representation of the ASCII letter “t”

If you just want backslash codes, you can use \116 to represent t. If you need Unicode, you should be able to look up a chart for it and do the conversions manually with a table. If you’re doing this to obfuscate your scripts, don’t do it this way.

Oh trust me id never use bytecode for obfuscation
:skull:

1 Like

How much do you care about Unicode?
If you just want ASCII codes that look like this
\116\101\115\116
that’s easy enough.

local input = "test, test2"
print("\\"..table.concat({string.byte(input, 1, #input)}, "\\"))
--> \116\101\115\116\44\32\116\101\115\116\50

The problem is that whole backslash notation thing doesn’t support true Unicode. Fancy Unicode symbols such as Ԙ won’t work. I’m not sure how to make that work either, since \u isn’t a thing.
Do you really need full Unicode support? If so, you won’t be able to use the backslash notation.

2 Likes

meh not really. Thank you. stuypid character limbnt

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.