I want to detect if a ban reason has unicode in it (as the way to ban someone is through Discord), so when I try to check the ban, it doesn’t break due to a unicode character, how do I detect this?
1 Like
for char in string.gmatch(ustring, "([%z\1-\127\194-\244][\128-\191]*)") do
-- something
end
According to the lua Guide on Unicode, this function will “iterate over UTF-8 sequences ([it] will simply skip over most invalid codes)”
1 Like
It still contains the unicode character in question
I still need help here
still?
1 Like
try this code
local function isUTF8(a)
for v1, v2 in utf8.graphemes(a) do
if v1 ~= v2 then
return true
end
end
return false
end
local hasUnicode = isUTF8("â")
print(hasUnicode) --> true
hasUnicode = isUTF8("a")
print(hasUnicode) --> false
hasUnicode = isUTF8("aâ")
print(hasUnicode) --> true