local function g(g,G)if G then g=string.sub(g,utf8.offset(g,G))end local F=utf8.len(g)if F<=1999 then return{n=F;s=g,utf8.codepoint(g,1,#g)}end local C=math.ceil(F/1999)local a=table.create(F)local N=1 for G=1,C,1 do local u=table.pack(utf8.codepoint(g,utf8.offset(g,G*1999-1998),utf8.offset(g,G*1999-(G==C and 1998-((F-1)%1999+1)or-1))-1))table.move(u,1,u.n,N,a)N+=u.n end a.s,a.n=g,F return a end local function G(g)local G=g.n or#g if G<=7997 then return utf8.char(table.unpack(g))end local F=math.ceil(G/7997)local C=table.create(F)for a=1,F,1 do C[a]=utf8.char(table.unpack(g,a*7997-7996,a*7997-(a==F and 7997-((G-1)%7997+1)or 0)))end return table.concat(C)end local function F(g,G,F)F=utf8.offset(g,F)return string.sub(g,utf8.offset(g,G),F and F-1)end
--
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;
