Problem in the Hebrew language Counting letters and from a word string, etc. In printing, you see a character instead of the letter

Why in the Hebrew language do I get by counting the letters in a multiple of 2
Can not print in Hebrew?
That’s the code

local selectOt2 = display.newText( “”,320,80, native.systemFont, 35 )
selectOt2.x = display.contentCenterX
selectOt2.y = display.contentCenterY*0.9
selectOt2:setFillColor( 1, 0, 0 )

local wordHeb = “תפוח”
print (string.len(wordHeb))
selectOt.text = (string.len(wordHeb))

local wordEn = “abcd”
print (string.len(wordEn))
selectOt2.text = (string.len(wordEn))

The long:
Lua I believe holds characters in an 8 bit. So characters that fall outside of the 8 bit are represented by 2 8bit slots. So when you use string.len() it is counting those 2 characters for Hebrew characters.

The short. You need to use this library instead:

I did not understand how I handle this,
Am I supposed to write code?
Or attach a plugin and call it?

I would love if someone could please guide how to do it.
Thank you

Like this:

            local utf8 = require( "plugin.utf8" )

            local selectOt2 = display.newText( "",320,80, native.systemFont, 35 )
            selectOt2.x = display.contentCenterX
            selectOt2.y = display.contentCenterY*0.9
            selectOt2:setFillColor( 1, 0, 0 )

            local wordHeb = "תפוח"
            print (utf8.len(wordHeb))
            selectOt2.text = (utf8.len(wordHeb))

Screenshot - This is what I get after running the code

Of course I also added in the file

settings =
{
plugins =
{
[“plugin.utf8”] =
{
publisherId = “com.coronalabs”
},
},
}

no need to add it into settings. I didn’t.

03.rar (217.3 KB)

I have attached the folder for you to see
Which is what I get I run the code

Your current error says:
buildsettings

Notice it says “buildSettings” is a nil value. This means that buildSettings couldn’t load. Either you don’t have the file or in this case, you do have the file and it is badly formatted.

Looking at your build settings you have a random curly bracket floating in the middle of the file:

Comment or delete that line and the file should load.