Tuesday, October 16, 2007

Unicode bug in RichTextBox

i found this today so i though of blogging it. there is a bug in the "_doc.Append" in the extended richtextbox. you have to replace that from this to work

replace:
_doc.Append(_text.Replace("\n", @"\par "));

with this:

string Text = _text.Replace("\n", @"\par ");
char[] chars = Text.ToCharArray();
for (int i = 0; i < chars.Length; i++)
{
if ((int)chars[i] > 256)
{
_doc.AppendFormat(@"\u" + ((int)chars[i]).ToString() + "?");
}
else
{
_doc.Append(chars[i].ToString());
}
}

No comments: