File tree Expand file tree Collapse file tree 1 file changed +28
-1
lines changed Expand file tree Collapse file tree 1 file changed +28
-1
lines changed Original file line number Diff line number Diff line change @@ -54,7 +54,34 @@ local function split(txt, sep)
54
54
for line in string.gmatch (txt , ' [^\n ]*' ) do
55
55
if sep == nil then
56
56
for str in string.gmatch (line , ' [\33 -\127\192 -\255 ]+[\128 -\191 ]*' ) do
57
- table.insert (result , str )
57
+ local codes = { }
58
+ for _ , v in utf8.codes (str ) do
59
+ table.insert (codes , v )
60
+ end
61
+ local j = nil
62
+ for i = # codes , 1 , - 1 do
63
+ if codes [i ] <= 255 then
64
+ break
65
+ end
66
+ j = i
67
+ end
68
+ if j == nil then
69
+ table.insert (result , str )
70
+ else
71
+ local first , second = ' ' , ' '
72
+ for k = 1 , j - 1 , 1 do
73
+ first = first .. utf8.char (codes [k ])
74
+ end
75
+ for k = j , # codes , 1 do
76
+ second = second .. utf8.char (codes [k ])
77
+ end
78
+ if first ~= ' ' then
79
+ table.insert (result , first )
80
+ end
81
+ if second ~= ' ' then
82
+ table.insert (result , second )
83
+ end
84
+ end
58
85
end
59
86
else
60
87
for str in string.gmatch (line , ' ([^' .. sep .. ' ]+)' ) do
You can’t perform that action at this time.
0 commit comments