Take a tour !
A quick overview of Luart
We can now use Luart to compute computations the same way as standard Lua :
As you can see, Lua is capable of handling a range of mathematical operations, thanks to its
math module and bits operators.
Luart offers iterable values, which can be iterated over. The term iterable refers to values that contain elements that can be iterated over one by one with the global
each() function :
In this example, you may have guessed that strings in Luart are iterable character by character. Nonetheless, Luart provides string properties that are not limited to this.
Since Lua 5.3 a new module
utf8 is available to help developers with UTF8 encoded strings. But this greatly complicates the use of UTF8 strings, as it uses specific functions. A kind of overlay over strings. Not very friendly : in other modern programming languages, strings are containers for characters and support natively multibytes encodings.
Luart consider strings as UTF8 encoded strings as any other modern programming language. That means all string functions consider characters to be UTF8 encoded:
Here, we defined a
summer_infrench variable containing the string "été" (it's the word "summer" in french !). This string contains 3 characters (hence the result with the
string.len() function). But the result of the
# operator is 5 !
It's because Lua's length operator always returns the number of bytes that a string occupies in memory. And the UTF8 string "été" uses 5 bytes :