In Lua language when I want to get the length of a single Arabic letter (such as "ف"
), the answer will be 2
!
Ex.
local letter = "ف"
print( letter:len() )
Output: 2
The same problem occur when I use (string.sub(a,b))
. If I want to print the first letter of an Arabic word, I can't say (string.sub(1,1)
.
Ex.
local word_1 = "فولت"
print( word_1:sub(1,2) )
Output: ف
as you saw I put the second argument (2) not (1) to get the correct answer.
if I put the first argument 1 the answer will be:
print( word_1:sub(1,1) )
Output: Ù
Why does Lua count the length of a single Arabic letter as a two?
And is there a way to get the right length which is 1?