public static string util_quotestring(string s)
{
return "\"" + Regex.Replace(s, @"[\\\r\n\t""\0]",
delegate(Match m)
{
switch (m.Value[0])
{
case '\r':
return @"\r";
case '\n':
return @"\n";
case '\t':
return @"\t";
case '"':
return @"\""";
case '\\':
return @"\\";
default:
return string.Format(@"\{0:000}", (int)m.Value[0]);
}
}) + "\"";
}