static string FromCSharpFormat(string text)
{
StringBuilder sb = new StringBuilder ();
for (int i = 0; i < text.Length; i++) {
char c1 = text[i];
if (c1 != '\\') {
sb.Append (c1);
continue;
}
i++;
char c2 = text[i];
switch (c2) {
case '\'':
case '"':
case '\\':
sb.Append (c2);
break;
case 'n':
sb.Append ('\n');
break;
case 'r':
sb.Append ('\r');
break;
case 't':
sb.Append ('\t');
break;
case 'U':
//FIXME UNICODE
//break;
case 'u':
//FIXME unicode
//break;
case 'x':
//FIXME hex unicode
//break;
//if (char.IsControl (c);
//case '0':
//case 'a':
//case 'b':
//case 'f':
//case 'v':
default:
throw new FormatException ("Invalid escape '\\" + c2 + "' in translatable string.");
}
}
return sb.ToString ();
}