전략게시판

전략게시판 [스튜디오]
문자열을 한 글자, 한 음절씩 분류하는 스크립트
2021.06.08 19:48 조회 : 1930
Lv. 451익스트림버니합 CosyClimbing 작성자 게시물 더보기
function UI.Event:OnChat(msg)
splitmsg(msg)
end

function splitmsg(msg)
local t = {}
local result = {}

for i = 1, msg:len() do
table.insert(t, string.byte(msg, i))
end
for i = 1, #t do
if t[i] then 
if t[i] < 128 then
table.insert(result, string.char(t[i]))
else
table.insert(result, string.char(t[i], t[i+1], t[i+2]))
t[i+1] = nil
t[i+2] = nil
end
end
end
for i = 1, #result do
print(result[i]) -- 결과 확인용
end
return result
end
추천 : 1
댓글을 남기시려면 로그인 해주세요
댓글 : 0