471,578 Members | 1,634 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,578 software developers and data experts.

Encoding ISO-8859-1 will not work

I have some big trouble getting special characters right when reading from a
mailbox. I have a class that reads e-mails from a mailboxusing pop3
(language C#). I have tried various approaches from suggestions that I have
received from newsgroups.

Here's a small sample from how the e-mail looks like just after it is
received: (some headers removed)

MIME-Version: 1.0
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: base64

Hi there! =
This is a test ISO-8859-1 =20

=3D=20

I have tried several ways to display this text correctly, for example this:
Encoding enc = Encoding.GetEncoding("iso-8859-1");
But var 'enc' does not display correctly.

If anyone can tell me what I am doing wrong or how to convert an e-mail,
written in ISO-8859-1 to normal text?

Greetings
Robert-Paul
http://www.robertp.nl
Nov 16 '05 #1
5 13609
Hi,

You should convert the message from the Quoted-Printable encoding to plain
text first.

--
Dmitriy Lapshin [C# / .NET MVP]
X-Unity Test Studio
http://x-unity.miik.com.ua/teststudio.aspx
Bring the power of unit testing to VS .NET IDE

Nov 16 '05 #2
> Encoding enc = Encoding.GetEncoding("iso-8859-1");

http://longhorn.msdn.microsoft.com/l...encodinginfo/m
/getencoding.aspx
in your case:
Encoding.GetEncoding( 28591 );
Nov 16 '05 #3
Your post is vague to say the least as to what you are actually doing and
what doesn't work, and what your symptoms are.
What do you mean by "But var 'enc' does not display correctly." Is it null ?

If you have a stream containing encoded binary data, you can read it using a
StreamReader class

Stream stream = // your stream!
Encoding enc = Encoding.GetEncoding("iso-8859-1"); // This SHOULD work
StreamReader reader = new StreamReader( stream, enc );
String str = reader.ReadToEnd();

"Robert-Paul" <so***@nomail.com> wrote in message
news:OX**************@TK2MSFTNGP12.phx.gbl...
I have some big trouble getting special characters right when reading from a mailbox. I have a class that reads e-mails from a mailboxusing pop3
(language C#). I have tried various approaches from suggestions that I have received from newsgroups.

Here's a small sample from how the e-mail looks like just after it is
received: (some headers removed)

MIME-Version: 1.0
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: base64

Hi there! =
This is a test ISO-8859-1 =20

=3D=20

I have tried several ways to display this text correctly, for example this: Encoding enc = Encoding.GetEncoding("iso-8859-1");
But var 'enc' does not display correctly.

If anyone can tell me what I am doing wrong or how to convert an e-mail,
written in ISO-8859-1 to normal text?

Greetings
Robert-Paul
http://www.robertp.nl

Nov 16 '05 #4

"Peter Strĝiman" <blah@blahblahblah> wrote in message
news:eV****************@TK2MSFTNGP11.phx.gbl...
Your post is vague to say the least as to what you are actually doing and
what doesn't work, and what your symptoms are.
What do you mean by "But var 'enc' does not display correctly." Is it null ?


This is what I have:

string x = "body of mail with the special caracters....";
StringReader str = new StringReader(x);
Encoding enc = Encoding.GetEncoding("iso-8859-1");
StreamReader reader = StreamReader(str,enc);
string z = reader.ReadToEnd();

And in 'z' is nothing converted to iso-8859-1.

This is correct?

Greetzzz
Robert-Paul

----
http://www.robertp.nl
Nov 16 '05 #5
Robert-Paul <so***@nomail.com> wrote:
This is what I have:

string x = "body of mail with the special caracters....";
StringReader str = new StringReader(x);
Encoding enc = Encoding.GetEncoding("iso-8859-1");
StreamReader reader = StreamReader(str,enc);
string z = reader.ReadToEnd();
That won't actually compile, both because you've forgotten the "new" in
the fourth line, and because there is no constructor for StreamReader
which takes a StringReader as its first parameter.
And in 'z' is nothing converted to iso-8859-1.

This is correct?


The mail itself no doubt has quoted-printable characters. You need to
convert those into ISO-8859-1. That only has a bit to do with Encoding
objects, which are used to convert *binary* to text, not quoted
printable text to text.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Nov 16 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

10 posts views Thread by Christopher H. Laco | last post: by
9 posts views Thread by PAN | last post: by
5 posts views Thread by DbNetLink | last post: by
5 posts views Thread by Michiel | last post: by
37 posts views Thread by Zhiv Kurilka | last post: by
4 posts views Thread by Ciuin | last post: by
reply views Thread by leo001 | last post: by
reply views Thread by lumer26 | last post: by
reply views Thread by Vinnie | last post: by
reply views Thread by lumer26 | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.