starwing / luautf8

a utf-8 support module for Lua and LuaJIT.
MIT License
412 stars 68 forks source link

Strange output with multi width emojis #19

Closed yangm97 closed 6 years ago

yangm97 commented 6 years ago

Using LUA 5.1 on macOS

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  🌈