Reputation:
I am trying to encode the text in a rich text box , so it appears as UTF-8
.
I am having some troubles however, and most online help posts aren't giving me how to return the converted text to the richtextbox.
private void encodeToolStripMenuItem_Click(object sender, EventArgs e)
{
UTF8Encoding utf8 = new UTF8Encoding();
string textstring;
string encodedString;
textstring = richTextBox1.Text;
byte[] encodedBytes = utf8.GetBytes(textstring);
richTextBox1.Clear();
encodedBytes.ToString(encodedString);
richTextBox1.Text = encodedString;
}
Upvotes: 0
Views: 5547
Reputation: 9519
Change encodedBytes.ToString(encodedString);
to encodedString = utf8.GetString(encodedBytes);
Upvotes: 3