I\'m trying to output unicode string into RTF format. (using c# and winforms)
From wikipedia:
If a Unicode escape is required, the control wor
Fixed code from accepted answer - added special character escaping, as described in this link
static string GetRtfUnicodeEscapedString(string s)
{
var sb = new StringBuilder();
foreach (var c in s)
{
if(c == '\\' || c == '{' || c == '}')
sb.Append(@"\" + c);
else if (c <= 0x7f)
sb.Append(c);
else
sb.Append("\\u" + Convert.ToUInt32(c) + "?");
}
return sb.ToString();
}