Lua string length. Oct 16, 2023 · Basic Manipulations with Lua Strings.
Lua string length String: "0123456789" (Length = 10) should be splitted in strings of 3 characters May 11, 2014 · The items are still in a hash table. Therefore, you can use the string functions in object-oriented style. 3333[code] Character and byte representation Character and Byte Representation An example code for converting the internal representation of a string from a string and vice versa. (That is the usual meaning of string length when each character is one byte. How to split string by string length and a separator? 2. If, after the translation of negative indices, i is less than 1, it is corrected to 1. sub with a byte index given by utf8. format() method is used to create formatted strings by replacing placeholders with specified values. Lua is 8-bit clean: strings can contain any 8-bit value, including embedded zeros ('\0'). Lua strings are immutable, meaning they cannot be changed after creation. Back to your question, in this piece of code. The string. Lua offers a wide range of functions for working with text. While still largely relevant for later versions, there are some differences. Mar 13, 2024 · Deep Dive. Learn how to use the Lua library functions for string manipulation, such as finding and extracting substrings, changing case, and formatting strings. Nov 16, 2020 · Exactly - Look at the arg table when you call lua -i - This table starts with 0 and the above code counts it correctly. So it doesn't looks like this: (line1): Long long long string (line2): string but more like this: (line1): Long string string string string (line2): string and this is the res of the string Sep 26, 2021 · lua string length. So it doesn't looks like this: (line1): Long long long string (line2): string but more like this: (line1): Long string string string string (line2): string and this is the res of the string Jan 20, 2017 · I tried the string. newText object's size. 3 and is available at Amazon and other bookstores. Here is a visual representation of this function: Hello, Educative! string. It also sets a metatable for strings where the __index field points to the string table. (See Programming in Lua) for the use of table. Memory consists of address and bytes. Jan 14, 2015 · In other words, a Lua string is a sequence of bytes, it doesn't support Unicode internally. Apr 15, 2014 · I'm trying to imlement my own length method for strings in Lua. 4 of the Reference Manual(Lua 5. There are various types of table length. sep. Sep 1, 2021 · The performance improved (between implementing ToH in Lua and table. String Length – string. char - Converts ASCII codes into their equivalent characters string. When indexing a string, the first character has position 1. gmatch() from Lua 5. i,F = 1,1 while i<10 do print(i. char, string. However, I stuck at writing a function which takes a wildcard-string to format, and a variable number of arguments to put Jun 22, 2020 · Not a lua expert but it seems like you're trying to get the length of the string value Bla. format to convert a string value to a long number and meet a strange issue. Long strings are compared using memcmp (if the lengths match), so you get O(n). sub. Apr 17, 2017 · To be clear, a Lua string is a counted sequence of bytes. 2 String Manipulation. As we mentioned earlier, Lua is Unicode agnostic. 4 prints: 1 1 2 nil 3 2 4 nil 5 3 6 nil 7 4 While LuaJIT prints: 1 1 As a result, I don't trust the length operator for this kind of things. format("%0. This means that in lua, #s (string length) is O(1) vs. The length of any string in Lua must fit in a Lua integer. This function returns the number of characters in the given string. 1) string. But this does not work with the multibyte. May 15, 2016 · The # operator finds the length of a string, among other things, great. len function. An “embedded zero” is a byte with the value 0 (zero). len() The string. What I mean is if i had a string named "str" and it was equal to "hello world", str = "hello world" it should somehow Mar 22, 2013 · I have a string, starting with a number, then a space, then a word of an unknown amount of letters, a space again, and then sometimes another piece of text (which may or may not contain more than one Returns the length of a string. g, assuming UTF-8 is used, you can use this snippet to count the length of a string (Referece: Lua Unicode): Jan 25, 2012 · I have a multibyte string in Lua. 1, you can iterate of the characters of a string this in a couple of ways. See Section 7. c) and change its handling of the opcode OP_LEN. You can easily find out the length of a string in Lua using the `#` operator. 2. Feb 6, 2014 · how to write a Lua pattern to convert string (nested array) into a real array? Hot Network Questions Geometric intuition on the relation between SVD and the four fundamentals subspaces Aug 13, 2013 · Lua has the # operator to compute the "length" of a table being used as an array. This is neat because it saves memory and makes string length operations fast. len(str) print(len) -- Outputs: 11 Sep 14, 2016 · Let's say I have a string with 2000 chars. e. See full list on tutorialspoint. Unicode agnostic is good enough for most things, but there are situations where this just doesn’t work, so we’ll introduce a library for working with utf8 in Lua as well. Lua arrays are unit offset, not zero offset. Basically, in Lua 5. com Learn how to use the string library to manipulate strings in Lua, such as extracting substrings, checking length, converting characters, and formatting output. I want to split this string in equal sized chunks of 500 chars, so I would end up with 4 strings of 500 chars. format is pretty straight forward, if you know what to format. local s = "あいうえお" How do I take the string and split it into a table of strings? In English texts, then I can use this code. sub(text,1,j) returns a prefix of text with length j, and string. Because it can hold almost ( except nil/empty ) everything as a key for a value. str5 Lua allocates only one new string, check out this loop from Lua's relevant source in luaV_concat: Basic formatting Lua Tutorial Date formatting 02/01/2014 0. The way you've written it right now does not indicate Bla is of string type. Both methods work the same way, and they both return a number value. Sep 15, 2020 · However, you generally don't need the length directly; what you really need is a table containing the elements in question. For a complete introduction to Lua programming, see the book Programming in Lua. len(str) method− Using string. Example using string. How can this be done in Lua, when neither the length of the initial string is fixed, nor the chunk size? Example. Aug 11, 2020 · You cannot delete the first character of a string. This number can be assigned to a variable or used in its place. Like all "-Value" objects, this single value is stored in the Value property. Share Oct 18, 2023 · Let us start treading the path of understanding by looking into the basic string functions provided by the Lua string library. The length of the string can't be more than 200,000 characters (this will cause a "String too long" error). The standard API provides support for two of the most basic string operations: substring extraction and string concatenation. str3 . See the syntax, example and output of this method. In Lua, strings are 1-indexed, meaning the first character of a string is at position 1. I am wondering the first times about it that a sequence in Lua dont start with a zero. Literal Unicode strings can appear in your lua programs. n can be different from the number of bytes of s. Jun 14, 2016 · Luas string. May be using fontSize for calculating coefficient Sep 9, 2019 · If you truncate a string at a byte index that is not between whole codepoints you will end up with an invalid UTF-8 string that may render incorrectly or cannot be stored in a DataStore. And the application may use lua Lua strings are just byte strings that keep track of their length, so they may contain any byte values, zero included. But you can copy a substring that starts from the second character using string. ']+)') do -- insert the substring in table table. May 20, 2024 · If you are splitting a string in Lua, you should try the string. If you change it to the following, this should work. 1, while cubuspl42 is correct for Lua 5. sub(text, -i) returns a suffix of text with length i. Data can be stored, formatted and encoded into a string buffer and later converted, extracted or decoded. – Jeremy Sep 1, 2023 · Getting the Length of an Array. Often it is valuable to access the length or size of an array. local result = str1 . dump - Converts a function into binary string. len() 函数是一个强大的工具,用于确定给定字符串的长度,它在各种字符串操作场景中发挥着关键作用。 Lua Basics Tutorial: Hello, aspiring programmers! Today, we're diving into the wonderful world of strings in Lua. The length of a string is its number of bytes (that is, the usual meaning of string length when each character is one byte). sub(s,1,j) returns a prefix of s with length j, and string. len() function, or by placing a # symbol in front of the string. find lua` function is an indispensable part of string manipulation that provides flexible and powerful searching capabilities within strings Jan 14, 2014 · You can compare the string's length first, if they are equal then compare from the first character, if there's one character that is different, then the rest must be the same for your condition to be true: The string buffer library allows high-performance manipulation of string-like data. Sep 9, 2023 · The . Unlike Lua strings, which are constants, string buffers are mutable sequences of 8-bit (binary-transparent) characters. Using == operator− We can compare a string with '' to check if it is empty. In Lua, we can check a String as empty or Null/Nil in multiple ways. concat in C) because while table. Format long number to shorter version in Lua. There are two ways to get the length of a string, either using the string. But in fact a table is more than just an array. You need to use a special trick to manipulate Unicode, e. , Ruby, Python). len but that . A string pode ser inicializada com três formas que incluem - Caracteres entre aspas simples Caracteres entre aspas duplas Personagens entre [[e]] Um exemplo para os três formulários acima é mostrado abaixo. Short strings on the other hand are "interned" meaning that when you create a certain short string in Lua Jul 22, 2022 · I am trying to write a function that produces a string of a fixed length. This is simple yet powerful for validating inputs or processing data. sub(s, -i) (for a positive i) returns a suffix of s with length i. But the keys are numeric and contiguous from 1 to N. len() function is used to get the length of a string. split and divide it with string. It was released before UTF8 support was built into Lua. If you are truncating a string at an index you should use string. Format integer in Lua. g. Aug 21, 2020 · 6. Lua: string of specific length. Sep 26, 2018 · function dec2hex(IN) local OUT OUT = string. They can be concatenated, sliced, and compared, but any modification will create a new string object. Nov 2, 2017 · The length operator is denoted by the unary operator #. The Lua idiom for this case is something like this: Given a string s in Lua: s = "abc123" If the string is non-empty, I want to store the first character of this string in a variable s1, else store nothing. It typechecks the argument to make sure it's a string, but otherwise returns the same value as #. Split lua string into characters. 4. format for a cleaner approach, similar to C’s printf. Some of functions in the string library operate on the assumption that those bytes are text when viewed with respect to the current locale. 3, there are two types, the integer type lua_Integer and the number type lua_Number. For practical examples of usage of the string library, have a look at StringRecipes. Here’s how you can use it: str = "Hello, Zenva" len = string. And the application may use lua However, there is a caveat to be aware of. Jul 5, 2024 · Learn how to use the . Oct 16, 2023 · Basic Manipulations with Lua Strings. gmatch(inputstr, '([^'. Historically, Lua lacked built-in string interpolation, unlike some other languages (e. Oct 23, 2018 · Find the string length of a Lua number? 2. That is the only way. Sep 24, 2020 · Yes. Assign to the integer n the number of characters of the string s. Additionally, many developers might struggle with escaping characters within strings. Presentation by Roberto Ierusalimschy (one of the creators of Lua) on the future of Lua, which talks about many things and one of them is UTF8 support. newText object according to text length. Make sure that multibyte characters are properly handled. Lua can call (and manipulate) functions written in Lua and functions written in C (see §3. Even your "long" strings are less than 40 bytes (LUAI_MAXSHORTLEN), so Lua treats them as short strings. string1 = "Lua" print("\"String 1 is\"",string1) string2 = 'Tutorial' print Lua - Array Length - It is a general convention that the size of the array is the number of elements that are present inside the array before the nil. Oct 23, 2018 · defines foo as a string of specific length " here is a string 00012" However, is there an easy way to get "here is a string 00012" I know, that I can fill up the string data with spaces. byte - Converts a character into its ASCII (decimal) equivalent string. If length is zero, then string is empty. format. Dashboard Learn Store Talent Forum Roadmap. Since strings in Lua are immutable, each concatenation creates a new string object and copies the data from the source strings to it. 3, if the second argument is a boolean true, then the first argument is treated as a raw Lua string of bytes to use, instead of a hexadecimal string. concat for concatenating many strings. ) Specifically, len and # return the number of bytes in the string, regardless of those bytes being encoded text. Creator Hub. 1)根据 repl 来做替换,并将最终的字符串返回。 Nov 12, 2014 · Regarding string comparisons (for equality): Newer Lua versions have two types of strings internally: short strings (usually up to 40 bytes) and long strings. Use the string. Is there an efficient and elegant way to truncate number like Jun 15, 2021 · Programming in Lua : 20. Apr 4, 2013 · Good one, but what it does is it splits string by last space but what I'm trying to make is that it splits by last space that is near at least 20/30 chars. Parameters. This first edition was written for Lua 5. Solution 1: In Lua, the string. In particular, the call string. If j is Jan 30, 2019 · In lua 5. If len is not NULL, it also sets *len with the string length. May 23, 2014 · Learn how to use the # symbol to get the length of a string or a table in Lua. There are two cases I think I need to consider: The string is too long and must be cropped The string is too short and mus Creates a new ByteArray object. Utils or PadLeft. The www. Strings in Lua have a maximum length of 2^31 – 1 bytes and are encoded in UTF-8 by default. This means that embedded zeros are counted in the length of a Lua string. 3 standard utf8 library. It is the standard length operator, and it's what you usually use to get the length of an object. concat. byte(s,i) can be written as s:byte(i). How can I get the returned string from the C function as a Lua string here: You should be able to pass strings of any length to ffi. Let's say I have a string with 2000 chars. See examples, syntax and differences with string. Lua strings are just byte strings that keep track of their length, so they may contain any byte values, zero included. String é uma sequência de caracteres, bem como caracteres de controle, como alimentação de formulário. Jan 20, 2017 · I tried the string. See examples of string. In a language such as C, after you've computed the length of something, you typically don't compute it again. What are Strings in Lua? Strings in Lua are a sequence of characters used to represent text. s: string The # operator returns string lengths and table lengths. Creating a string in Lua is simple. sub() methods. In either case, the whole thing is completely insane. To handle multibyte charsets, you need a library like utf8 , which is available in Lua 5. 2. 17g", 76561197971049296)) If number is an IEEE-754 double, then it doesn't work. len. Here is how I see to do that: Get number of lines (number of "\n" + 1, because where is no "\n" in the end) In for loop get the longest line; Set display. str2 . sub() method if you know the index you wish to split the string at, or use the string. string. local s = "foo bar 123" local words = {} for word in s:gmatch("%w+") do table. lower or any other string function not working. len() 函数:一个全面的指南. So the length of this string “a 00bc 00” (or “a 0bc 0” or “a bc ”) would be five. – Lua Strings Properties. But if want to manipulate string inside the memory then use byte conversion is more easy. 1. You can find details about the string library in section 5. Returns the length of a string. len() function is used to get the size of a string. 1 by default uses doubles as only number type, which may lead to a loss of precision when coercing large numbers. A method is just a function, taking the string as the first parameter. Here is an example code snippet demonstrating the use of string. ) You can also call print(#a) to print a 's length. len() function calculates the length of a given string. String manipulation is a crucial aspect of programming in Lua. You do have to know how your Lua is implemented and keep in mind the the technical limitations. If the value is a number, then lua_tolstring also changes the actual value in the stack to a string. Share . 3 Reference Manual The reference manual is the official definition of the Lua language. gfind - Iterate over a string (obsolete in Lua 5. The string library assumes one-byte character encodings. The package extends default Lua's string library with several useful common methods which are present in most other languages. Using string. I can't use String. You can get their lengths programatically from within Lua by parsing a chunk header: Nov 4, 2021 · a = "string" a:len() Or: a = "string" #a EDIT: your original code is not idiomatic but is also working > a = "string" > a. Lua 字符串 字符串或串(String)是由数字、字母、下划线组成的一串字符。 在 Lua 中,字符串是一种基本的数据类型,用于存储文本数据。 Aug 9, 2023 · Strings are a sequence of characters of any length that can include letters, numbers, symbols, and spaces. byte and UTF8 in Lua is available at: Standard Lua string library. . format function to control the conversion: assert( "76561197971049296" == string. insert(t, str) end Mar 27, 2012 · 『Programmng in Lua』を読み返してみると、p. See Patterns for pattern specifiers. find - Searches a string for a pattern string. May 4, 2016 · Like @Roddy said, it's slightly complicated with the integer type. If you ever missed split, trim and other functions the this package provides such functions by extending Lua's default string library May 29, 2024 · If j is absent, then it is assumed to be equal to -1 (which is the same as the string length). As it was pointed out in the comments, lua strings are interned, which means that any two strings that have the same value are actually the same string. The `string. Some functions treat these byte strings as if they were C strings that terminate with \0, apparently print does this. len() 17. 1) and in section 6. Now I need to resize my display. format("%x",IN) return OUT end and need IN to have padded zeros to string length of 6. 4. To extract a substring, remember that the basic operation lua_pushlstring gets the string length as an Apr 21, 2014 · Find the string length of a Lua number? 9. 3). len but that Split lua string into characters Jan 30, 2019 · In lua 5. As your friendly neighborhood computer teacher, I'm excited to guide you May 3, 2011 · More information about string. Programming in Lua Part III. Apr 19, 2020 · string. All you need to do is assign a sequence of characters to a Apr 4, 2013 · Good one, but what it does is it splits string by last space but what I'm trying to make is that it splits by last space that is near at least 20/30 chars. How can I do this without knowing the length of the string? For example, the Unicode Lua programs. len() function returns string lengths. " " end Sep 14, 2016 · I need to split a string in equal sized chunks (where the last chunk can be smaller, if the strings length can't be divided without remainder). Creating and Displaying a String. If want to replace, insert, etc in a string/text then take a look for lua string library or lua string manipulation, example has given by DaSpammer, Aylin. In Lua, the # symbol is prepended to the array to return the length. Aug 5, 2020 · Checking the Length of a String - Scripting Support Loading String Manipulation Functions Getting String Length. You can call either method on a variable, or directly on a Aug 13, 2020 · I'm trying to split a string on a space in Lua. Lua is also encoding-agnostic; it makes no assumptions about the contents of a string. 35に以下のような記述がありました。 配列に穴がある―途中にnilの要素がある―と、長さ演算子はこれらのnil要素のいずれかを末尾を意味するマーカーとみなしてしまうかもしれません。 Mar 29, 2015 · I have a string x: x = "{abc}{def}{ghi}" And I need to print the string between second { and second }, in this case def. Syntax string. (Locale includes a character encoding. Jul 3, 2022 · This is a Lua "feature" called coercion: Lua will coerce strings to numbers if a number is expected and vice versa. String, float, double, etc just the types of value. len function: 0000000065ba16e0 > a. And there's table. lua-- define a function to spring a string with give separator function mysplit (inputstr, sep) -- if sep is null, set it as space if sep == nil then sep = '%s' end -- define an array local t={} -- split string based on sep for str in string. The Lua value must be a string or a number; otherwise, the function returns NULL. It's within an app called Watchmaker which uses a cut down version of Lua. len() method to get the length of a string in Lua. However, it is possible to use other encodings by If j is absent, then it is assumed to be equal to -1 (which is the same as the string length). len, string. format(format, value1, value2, ) format: A format string that defines the structure of the output string. We will look at string creation, finding string length, and string concatenation. Nov 4, 2021 · The length of a string is its number of bytes. Be sure to use the correct escape sequences to include special characters, such as `\"` for double quotes or `\\` for a backslash. ) Mar 13, 2024 · A detail worth noting: Lua keeps strings immutable and internally reused through a mechanism called string interning. concat implements a version of brute force algorithm, it does it in a memory efficient way (doubling the buffer size when there is not enough space), which extends the buffer if possible instead of re-allocating it for every string addition. The basic loop would be: for i = 1, #str do local c = str:sub(i,i) -- do something with c end. You'd need to modify the Lua source, specifically the virtual machine (lvm. The string library provides all of its functions inside the table string. strfind (str, substr, [init, [end]]) Receives two string arguments, and returns a number. gsub (s, pattern, repl [, n]) 拷贝整个字符串 s (或者前 n 个,如果传了此参数的话),将其中每个遇到的 pattern 匹配和捕获(参见6. You can't do this from Lua. Sep 10, 2023 · 深入理解 Lua 中的 string. If len is not NULL, it sets *len with the string length. insert( words, word ) end String length. the default is working fine. 3. org Lua String Manipulation. This will return a table containing all of the elements, and the length will be at the key "n" , which allows you to iterate over even the embedded nil elements of . O(n) for C strings. Lua 5. Nevertheless, the Lua API provides some functions to help with those tasks. Oct 20, 2016 · I'm trying to create a split() function in lua with delimiter by choice, when the default is space. This library provides generic functions for string manipulation, such as finding and extracting substrings. pack() . In C/C++ and some other languages it is used as a string terminator. For example, a search of a 40,000-character article text, for 99 separate words (passed as 99 parameters in a template), ran within one second of Lua CPU clock time. String to number conversion. 在 Lua 编程语言中,字符串操作是至关重要的。String. To build this, call table. They play a crucial role in many programming tasks, from storing user inputs to processing data. Converts the Lua value at the given acceptable index to a C string. Format string to number with minimum length in Apr 17, 2017 · To be clear, a Lua string is a counted sequence of bytes. But with Lua being dynamically typed, thus no conversion operators, how does one type a number as a string in order to determine its length? For example suppose I want to print the factorials from 1 to 9 in a formatted table. Lua includes two methods of determining the length of a string; the length operator # and the library function string. By buying the book, you also help to support the Lua project . gmatch() or string. Example Dec 25, 2018 · @Mircode The time needed for hashing isn't taken into account in your micro-benchmarks at all. Mania -- Strings are immutable. Short strings are hashed when they are created, which happens at compile/load time in your case, because all your keys are constants in your code. sub() for the international version. Jul 11, 2014 · This string is a poetry for some picture. lua string length Comment -2 Popularity 10/10 Helpfulness 1/10 Language lua. len(): main. len() method, we can pass the string as argument and get the required length. For some Dec 24, 2014 · In lua '==' for string will return true if contents of the strings are equal. In many cases, nil is not allowed in the array, but for some applications, it is not an issue to have nil inside them. See Also In Lua, the string. If j is absent, then it is assumed to be equal to -1 (which is the same as the string length). The basic loop would be: for i = 1, #str do local c = str:sub(i,i) -- do something with c end Converts the Lua value at the given index to a C string. lua. Concatenation with . The length of a table t is defined to be any integer index n such that t[n] is not nil and t[n+1] is nil; moreover, if t[1] is nil, n can be zero. Lua string. string – hugomg. 3 introduced string. Moreover, it depends on how your Lua is compiled. 1 Reference Manual: The string-search functions in Lua script can run extremely fast, comparing millions of characters per second. Source: Grepper. Apr 26, 2018 · Format string to number with minimum length in lua. Jan 5, 2023 · String comparison in Lua is constant time because Lua interns all strings as they are created (which means different string get different references, equal strings get equal references, which both means (1) the string isn't stored twice, (2) string comparison is reference comparison), so you don't need to worry about the cost of string 对于此函数,pattern 开头中的锚点 '^' 将不会生效,因为其会阻止迭代。 string. I've tried the following, but both return nil: s1 = s[1] s1 = s[0] How can I get the first character without using external Lua libraries? Mar 13, 2024 · Deep Dive. gmatch - Iterate Let’s get into the string operations in Lua. offset. "! May 11, 2014 · The result is also different in different implementations of Lua, for example, given: local a = { 1, nil, 2, nil, 3, nil, 4 } for k, v in npairs(a) do print(k, v) end Lua 5. 0. Oct 23, 2013 · You can use the string. Note: This syntax will return the last index, in some cases this may not be equivalent to the size of the array. 10). 3. Let’s kick things off with some basic manipulations that you can perform with Lua strings. sub(s, i [,j]) Returns the substring of s that starts at i and continues until j; i and j can be negative. For instance, string. The Arabic letter "ف" has 2 bytes, so Lua treats it as a string of length 2. What's important to note is that Lua strings are immutable, meaning that once a string is created, it cannot be modified. Idiom #169 String length. Starting in version 1. Syntax. The function strlen (s) returns the length of a string s . Tags: lua string-length. str4 . How to format a string longer than 99 characters in Lua. len(a) 6 The string a is linked to a table (named metatable) containing all the methods, including len. The fourth edition targets Lua 5. format - Formats a string string. 11. It allows developers to work with text data efficiently, enabling tasks such as parsing, formatting, and transforming strings. 2 for some examples on string manipulation in Lua. Use string. 6. sub, string. gmatch() if you will parse the string to find the location to split the string at. byte, and string. 4 文字列操作 このライブラリは部分文字列の検索・抽出やパターンマッチングといった文字列操作のための一般的な関数を提供します。Lua で文字列にアクセスするときのインデックスは最初の文字が 1 です (C のように 0 ではありません)。負のインデックスも使うことができ、文字列の最後 A StringValue is an object whose purpose is to store a single Lua string. Visual Dec 21, 2017 · The length of strings in Lua is the number of bytes in it, not the number of chars. len('len') returns the length of the string. gsub('This is a test', '%s', '-') returns the first parameter with each occurrence of the pattern indicated by the second parameter replaced by the third parameter. Hot Network Questions Lua 5. while data:len() < 50 do data = data. was the go-to way. In Lua, a string is a sequence of characters surrounded by a pair of single quotes '' or double quotes "". a = 'this is a string' View another examples Nov 29, 2015 · Lua : Incorrect string length for String with Special Characters. lower('LOWER') returns the string converted to lower case. If you need to change a string Apr 19, 2020 · string. That makes successive concatenations to a single string have very poor performance. Link to this answer Share Copy Link Apr 26, 2018 · Lua: string of specific length. Immutable simply means unmodifiable or unchangeable. Either a UTF-8 encoded string can appear directly with 8-bit characters or you can use the \ddd syntax (note that ddd is a decimal number, unlike some other languages). The problem starts when I give a delimiter to the function. number. sub() works with English text only, use utf8. The bottom line is that if you do not know if the table you have formed meets the Lua criteria for an array then you must count up the items in the table to know the length of the table. Regarding valid results: u0b34a0f6ae is correct for Lua 5. It contains placeholders and formatting options. ixnzq iuthrrs egozk sgc akr pzkw gecuq mvrub alrj pizdddv nwv bzlfzbr gmh lgrxi uadh