473,395 Members | 2,795 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 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 13725
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

48
by: Zenobia | last post by:
Recently I was editing a document in GoLive 6. I like GoLive because it has some nice features such as: * rewrite source code * check syntax * global search & replace (through several files at...
10
by: Christopher H. Laco | last post by:
Long story longer. I need to get web user input into a backend system that a) only grocks single byte encoding, b) expectes the data transer to be 1 bytes = 1 character, and c) uses the HP Roman-6...
9
by: PAN | last post by:
I need some guidance here I've written this HTML code using the Windows Notebook: <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EL"> <html> <head> <title>This is a Greek language title ->...
5
by: DbNetLink | last post by:
I am trying to convert some Japanese text encoded as Shift-JIS/ISO-2022-JP to UTF-8 so I can store all data in my database with a common encoding. My problem is the encoding conversion code works...
5
by: Michiel | last post by:
problem: pasting characters from MSWord into wysiwyg editor (tinyMCE) When we paste text from Word (i.e. MSWindows) to the browser, and in the text is any special character, like smart quotes,...
37
by: Zhiv Kurilka | last post by:
Hi, I have a text file with following content: "((^)|(.* +))§§§§§§§§" if I read it with: k=System.IO.StreamReader( "file.txt",System.Text.Encoding.ASCII); k.readtotheend()
4
by: Ciuin | last post by:
Hi all, I need to mail() emails with user input that does contain non-ascii (umlauts, accents) and non-latin (cyrillic) characters in the "Subject:" and "From:" headers. I understand that they...
6
by: saumya.agarwal | last post by:
Hi, I am using libxml2 for xml parsing. When the client application sends data to libxml2 in UTF-8 format, it works fine. But, I have a scenarion in which the client application sends data to...
4
by: kettle | last post by:
Hi, I am rather new to python, and am currently struggling with some encoding issues. I have some utf-8-encoded text which I need to encode as iso-2022-jp before sending it out to the world. I am...
2
by: Jeffrey Walton | last post by:
Hi All, BMP Strings are a subset of Universal Strings.The BMP string uses approximately 65,000 code points from Universal String encoding. BMP Strings: ISO/IEC 10646, 2-octet canonical form,...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.