local utf8 = require 'utf8'
local t = {}
local str = "text 😅 👨💻 🇧🇷 🏳️🌈"
for i=1, utf8.len(str) do
t[i]= (utf8.sub(str,i,i))
end
for k , v in pairs(t) do
print(k,v)
end
Output:
1 t
2 e
3 x
4 t
5
6 😅
7
8 👨
9
10 💻
11
12 🇧
13 🇷
14
15 🏳
16 ️
17
18 🌈
Using LUA 5.1 on macOS
Output: