local A={["\n"]="\110",["\r"]="\114";["\t"]="\116",["\012"]="\102";["\a"]="\097";["\v"]="\118";["\092"]="\092"}local m={}for A in pairs(A)do table.insert(m,A)end local Y=("\091\037\115\037\037\099\093"):format(table.concat(m,""))local function x(m)return m:gsub(Y,function(m)return"\092"..(A[m]or("\037\048\051\100"):format(m:byte()))end)end return x
local ESCAPES = {
	["\n"] = "n",
	["\r"] = "r",
	["\t"] = "t",
	["\f"] = "f",
	["\a"] = "a",
	["\v"] = "v",
	["\\"] = "\\",
}
local ESCAPE_CHARS = {}
for char in pairs(ESCAPES) do
	table.insert(ESCAPE_CHARS, char)
end
local ESCAPE_CLASS = ("[%s%%c]"):format(table.concat(ESCAPE_CHARS, ""))

local function escapeString(str)
	return str:gsub(ESCAPE_CLASS, function(match)
		return "\\" .. (ESCAPES[match] or ("%03d"):format(match:byte()))
	end)
end

return escapeString
