public static string FromGettextFormat(string text)
{
StringBuilder sb = new StringBuilder ();
for (int i = 0; i < text.Length; i++) {
char c = text[i];
switch (c) {
case '\\':
if (i + 1 < text.Length) {
char nextChar = text [i + 1];
if (nextChar == '\\' || nextChar == '"') {
sb.Append (nextChar);
i++;
continue;
}
if (nextChar == 'n') {
sb.Append ('\n');
i++;
continue;
}
if (nextChar == 't') {
sb.Append ('\t');
i++;
continue;
}
if (nextChar == 'r') {
sb.Append ('\r');
i++;
continue;
}
throw new FormatException (String.Format ("Invalid escape sequence '{0}' in string: '{1}'",
nextChar,
text));
}
break;
}
sb.Append (c);
}
return sb.ToString ();
}