function Util.SubstituteArgs(H,o)H=encodeCommandEscape(H)if type(o)=="\116\097\098\108\101"then for H=1,#o,1 do local M=tostring(H)o[M]=o[H]if o[M]:find("\037\115")then o[M]=string.format("\037\113",o[M])end end end return decodeCommandEscape(H:gsub("\036\040\037\119\043\041",o))end

function Util.SubstituteArgs(str, replace)
	str = encodeCommandEscape(str)
	-- Convert numerical keys to strings
	if type(replace) == "table" then
		for i = 1, #replace do
			local k = tostring(i)
			replace[k] = replace[i]

			if replace[k]:find("%s") then
				replace[k] = string.format("%q", replace[k])
			end
		end
	end
	return decodeCommandEscape(str:gsub("$(%w+)", replace))
end
