C
Chance Hopkins
I have an app that uses a socket to grab some data and ASCII encodes it to
store in a file.
Some times the data is supposed to be utf8 and start with =?Utf-8? when I
view it with notepad.
I'm trying to turn it back into the original text like so:
----------------------------------
if(myString.StartsWith("=?Utf-8?"))
{
//SOMEWHERE IN THESE TWO LINES IS THE ISSUE
byte[] temp = System.Text.ASCIIEncoding.Convert(System.Text.Encoding.UTF8,
System.Text.Encoding.ASCII,
System.Text.ASCIIEncoding.ASCII.GetBytes(currentMsg.Subject));
lblSubject.Text = "Subject: " +
System.Text.Encoding.ASCII.GetString(temp,0,temp.Length);
temp = null;
}
else
lblSubject.Text = myString;
----------------------------------
I just don't understand which encoding I have.
When I GetBytes, should it be ascii or utf8? (I think ascii)
When I Convert, am I going from ascii to utf8 or utf8 to ascii?
Can someone point me in the right direction, please.
Thanks.
store in a file.
Some times the data is supposed to be utf8 and start with =?Utf-8? when I
view it with notepad.
I'm trying to turn it back into the original text like so:
----------------------------------
if(myString.StartsWith("=?Utf-8?"))
{
//SOMEWHERE IN THESE TWO LINES IS THE ISSUE
byte[] temp = System.Text.ASCIIEncoding.Convert(System.Text.Encoding.UTF8,
System.Text.Encoding.ASCII,
System.Text.ASCIIEncoding.ASCII.GetBytes(currentMsg.Subject));
lblSubject.Text = "Subject: " +
System.Text.Encoding.ASCII.GetString(temp,0,temp.Length);
temp = null;
}
else
lblSubject.Text = myString;
----------------------------------
I just don't understand which encoding I have.
When I GetBytes, should it be ascii or utf8? (I think ascii)
When I Convert, am I going from ascii to utf8 or utf8 to ascii?
Can someone point me in the right direction, please.
Thanks.