Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local arg_split = utf8.char(2^16-2)
- local function sargs(str)
- local r = string.split(str,arg_split)
- local t = {}
- if 0 >= #r then
- r = {str}
- end
- for i,v in pairs(r) do
- if not (v and #v > 0) then
- r[i] = nil
- end
- end
- local c = 0
- for i,v in pairs(r) do
- c = c + 1
- t[c] = v
- end
- return t
- end
- local function unpack_str(str)
- return table.unpack(sargs(str))
- end
- local function pack_str(...)
- local t = {...}
- local r = ''
- for i,s in pairs(t) do
- s = string.gsub(s,arg_split,'')
- r = r .. s
- if #t > i then
- r = r .. arg_split
- end
- end
- return r
- end
- -- toast
- local packed = pack_str('a','b','c')
- print(packed)
- warn(unpack_str(packed))
Add Comment
Please, Sign In to add comment