local function J(J,Y)if Y then J=string.sub(J,utf8.offset(J,Y))end local U=utf8.len(J)if U<=1999 then return{n=U;s=J,utf8.codepoint(J,1,#J)}end local u=math.ceil(U/1999)local e=table.create(U)local Z=1 for Y=1,u,1 do local V=table.pack(utf8.codepoint(J,utf8.offset(J,Y*1999-1998),utf8.offset(J,Y*1999-(Y==u and 1998-((U-1)%1999+1)or-1))-1))table.move(V,1,V.n,Z,e)Z+=V.n end e.s,e.n=J,U return e end local function Y(J)local Y=J.n or#J if Y<=7997 then return utf8.char(table.unpack(J))end local U=math.ceil(Y/7997)local u=table.create(U)for e=1,U,1 do u[e]=utf8.char(table.unpack(J,e*7997-7996,e*7997-(e==U and 7997-((Y-1)%7997+1)or 0)))end return table.concat(u)end local function U(J,Y,U)U=utf8.offset(J,U)return string.sub(J,utf8.offset(J,Y),U and U-1)end
--[[ Functions ]]
--
local function to_str_arr(self, init)
	if init then
		self = string.sub(self, utf8.offset(self, init))
	end
	local len = utf8.len(self)
	if len <= 1999 then
		return { n = len, s = self, utf8.codepoint(self, 1, #self) }
	end
	local clen = math.ceil(len / 1999)
	local ret = table.create(len)
	local p = 1
	for i = 1, clen do
		local c = table.pack(
			utf8.codepoint(
				self,
				utf8.offset(self, i * 1999 - 1998),
				utf8.offset(self, i * 1999 - (i == clen and 1998 - ((len - 1) % 1999 + 1) or -1)) - 1
			)
		)
		table.move(c, 1, c.n, p, ret)
		p += c.n
	end
	ret.s, ret.n = self, len
	return ret
end

local function from_str_arr(self)
	local len = self.n or #self
	if len <= 7997 then
		return utf8.char(table.unpack(self))
	end
	local clen = math.ceil(len / 7997)
	local r = table.create(clen)
	for i = 1, clen do
		r[i] = utf8.char(
			table.unpack(self, i * 7997 - 7996, i * 7997 - (i == clen and 7997 - ((len - 1) % 7997 + 1) or 0))
		)
	end
	return table.concat(r)
end

local function utf8_sub(self, i, j)
	j = utf8.offset(self, j)
	return string.sub(self, utf8.offset(self, i), j and j - 1)
end
