Hi folks - I need your help. I am tring and searching to get rid of this problem for several days but somehow I did not manage it: I like to use some .NET code to read and interpret my e-mails automatically.
Basically it works fine, only some UTF characters are disturbing my work. This is what happens: E-mail header says a mail is encoded with UTF-8. For to read my mails I use ReadLine() from StreamReader class. I store the return values in a String class object.
As far as I know, StreamReader is set to UTF-8 by default. I have also read that String class objects are unicode. Because UTF-8 also is unicode I do not understand that I get return values as "=C3=A4" or "=E2=80=9C" within the normal text.
Besides:
StreamReader^ reader = gcnew StreamReader(sslstream);
I have tried:
StreamReader^ reader = gcnew StreamReader(sslstream, Encoding::UTF8, false);
and
Encoding ^enc = Encoding::GetEncoding("utf-8");
StreamReader^ reader = gcnew StreamReader(sslstream, enc, false);
(where
false is to prevent automatic search for some start up byte orders for encoding indentifiers)
Nothing changes and I don't know why...
What I find strange is (when debugging the StreamReader object) that I find StreamReader's "CurrentEncoding"-Value set to
CurrentEncoding = 0x00c6bfa4 { CodePageASCII=20127 ISO_8859_1=28591 ...}
I think the encoding mode is the problem. When StreamReader tries to read the mail in ASCII mode it must have a problem with special characters. The only questions is, how can I force it to switch to unicode/UFT-8. It seems to have no effect - whatever I do - when creating the StreamReader object.
Can you help? Thanks a lot!