-
What do you want to achieve? I want string.sub to work
-
What is the issue? string.sub doesn’t work with russian characters for some reason
-
What solutions have you tried so far? I tried turning the russian characters in the string into their english counterpart on the keyboard but that didn’t work either. What I mean is that for example, an “Ы” would be a “Y”. So the word “пистолет” would be “gbcnjtk”.
![изображение](//devforum-uploads.s3.dualstack.us-east-2.amazonaws.com/uploads/original/5X/b/6/0/3/b6039ce61158cc39ded833cd0c76fb4af5d5f95f.png)
local russ = "ГА"
print(string.sub(russ, 2,2))
This code always returns the question mark sign (it’s supposed to say “А”):
![изображение](//devforum-uploads.s3.dualstack.us-east-2.amazonaws.com/uploads/original/5X/7/3/f/3/73f347b015f4c60d6750cb9b5157be59f9357ded.png)
please help me
1 Like
It seems to be because characters such as Ы and Г are counted as 2 seperate characters, due to the way Unicode works. Accessing just one of the 2 characters in each returns the question mark.
As for solutions: I’m not entirely sure what the best way of going about it is.
aw man I wanted to make a letter spelling game for my lil bro
Don’t give up hope! There’s a unicode library available (utf8
) which I’ll examine to see if I can get it to work how you want.
In the meantime, attempting to access said library uncovered a bug in Roblox Studio, so I’ll probably report it.
alright, thank you very much ![:slight_smile: :slight_smile:](https://doy2mn9upadnk.cloudfront.net/images/emoji/twitter/slight_smile.png?v=12)
Good news! I found a way on how to get it working.
It relies on looping through the entire string, but based on your use case that should be fine.
local russ = "ГА"
for first, last in utf8.graphemes(russ) do
char = string.sub(russ, first, last)
print(char)
end
The above code will output Г, then А
edit: Here’s the report I posted about the bug I mentioned earlier.