# string length operator


As stated in the Lua 5.4 programming manual (see The Length Operator), the returned length of a string is its number of bytes. This behaviour is respected in Luart to preserve compatibility with standard Lua with ASCII characters.

To get the length in characters for UTF8 strings, do not use the # operator, use string.ulen() instead.

Example

-- declare an UTF8 string local summer_in_french = "�t�" -- outputs 5 (in bytes) print( #summer_in_french ) -- outputs 3 (in characters) print( summer_in_french:wlen() )