starwing/luautf8

Strange output with multi width emojis

yangm97 opened this issue ยท 0 comments

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	๐ŸŒˆ