lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


Le 2021-01-21 18:18, Egor Skriptunoff a écrit :
string.sub(str, pos1, pos1)
pos2 = string.find(str, "()%w", pos3)
string.byte(str, pos4)
Are they byte positions or character positions?

LuaRT uses character position for all strings functions

For all string functions, including string.unpack() and string.byte()
?

String.byte returns one or more bytes (byte séquence or UTF8 characters goes to one to 4). To manipulate bytes sequence in LuaRT the use or a Buffer is better.

String.unpack() is here to preserve standard Lua compatibility but the use or Buffer:pack() is better.

Regards,

Samir