static string EscapeString (string text)
{
StringBuilder sb = new StringBuilder ();
+
+ sb.Append ('"');
for (int i = 0; i < text.Length; i++) {
char c = text[i];
string txt;
case '\t': txt = @"\t"; break;
default:
if (char.GetUnicodeCategory (c) == UnicodeCategory.OtherNotAssigned) {
- sb.AppendFormat ("\\u{0:x4}", (int) c);
+ sb.AppendFormat ("\\u{0:X4}", (int) c);
} else {
sb.Append (c);
}
}
sb.Append (txt);
}
+ sb.Append ('"');
+
return sb.ToString ();
}