Jump to content
  • 0

Special Characters Not Recognized


HorridModz

Question

Help me!

I was making a script encoder, when I ran into a major problem. Apparently, string processing commands like string.sub do not support special characters like ☺ and 㐪 and  and ␇␈. They only work on common characters, like the ones I can directly type on my keyboard (ie: '!','2','J','j','{',':',etc.). I am using the default local in gameguardian, but I do not think that affects it.

For example, here is outputted when I directly use this special characterwithout doing any string manipulation on it:

print("☺")

Script ended:

 But when I do this exact thing, but with string manipulation commands, this is the output:

print(string.sub("☺", 1, 1))

Script ended:

Let's try with a non-special character:

print("a")

Script ended:
a

print(string.sub("a", 1, 1))

Script ended:
a

This does not apply to all commands. Let's use a command that is not from the lua string libary:

 

 

print("☺" .. "")

 

Script ended:

 

Now, why is this a problem? I need to read and encrypt characters one by one. The only way to get a character one by one is using string.sub (a member of the lua string library), like the code above, or at least this is claimed by the official lua documentary:

https://www.lua.org/pil/20.html

I have tried this code, but lua does not let me iterate through string:

for i in "☺" do
print(i)
end

 

How can you help?

If you have any ideas, please tell me a way to input this:

characters = "☺a"
print(string.sub(characters, 1, 1)) -- replace this with your code to print "☺"! You may not type "☺" anywhere in the code besides the first line (characters = "☺a") as this defeats the purpose.

and output this:

Script ended:

 

Thanks so much for reading!

Link to comment
Share on other sites

3 answers to this question

Recommended Posts

1. lua support text manipulation only with Unicode characters, so using emojis and special characters won't work.

2. you can loop through a string like this 

local str = "Hello World !"

for char in str:gmatch "." do 
  print (char)
end 

 

Link to comment
Share on other sites

2 hours ago, HorridModz said:

Help me!

I was making a script encoder, when I ran into a major problem. Apparently, string processing commands like string.sub do not support special characters like ☺ and 㐪 and  and ␇␈. They only work on common characters, like the ones I can directly type on my keyboard (ie: '!','2','J','j','{',':',etc.). I am using the default local in gameguardian, but I do not think that affects it.

For example, here is outputted when I directly use this special characterwithout doing any string manipulation on it:

print("☺")

Script ended:

 But when I do this exact thing, but with string manipulation commands, this is the output:

print(string.sub("☺", 1, 1))

Script ended:

Let's try with a non-special character:

print("a")

Script ended:
a

print(string.sub("a", 1, 1))

Script ended:
a

This does not apply to all commands. Let's use a command that is not from the lua string libary:

 

 

print("☺" .. "")

 

Script ended:

 

Now, why is this a problem? I need to read and encrypt characters one by one. The only way to get a character one by one is using string.sub (a member of the lua string library), like the code above, or at least this is claimed by the official lua documentary:

https://www.lua.org/pil/20.html

I have tried this code, but lua does not let me iterate through string:

for i in "☺" do
print(i)
end

 

How can you help?

If you have any ideas, please tell me a way to input this:

characters = "☺a"
print(string.sub(characters, 1, 1)) -- replace this with your code to print "☺"! You may not type "☺" anywhere in the code besides the first line (characters = "☺a") as this defeats the purpose.

and output this:

Script ended:

 

Thanks so much for reading!

If you have some linux environment, you might perform nano command to see emoji's in utf-8 wich non-Unicode. After you get the idea, it might look like this : "\\M blablabla" and then search using that string. Above answers is good, just casting an alternative idea.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.