Lua is 8-bit clean.
In other words, a Lua string is a sequence of bytes, it doesn't support Unicode internally. The Arabic letter "ف"
has 2 bytes, so Lua treats it as a string of length 2.
You need to use a special trick to manipulate Unicode, e.g, assuming UTF-8 is used, you can use this snippet to count the length of a string (Referece: Lua Unicode):
local _, count = string.gsub(unicode_string, "[^\128-\193]", "")