tags:

views:

65

answers:

3

I retrieve a stream. Everything works fine but the encoding of Umlaute (ä,ö,ü,ß).

What is

NäüßÖ´sas so viele Umlaute

becomes

NäüÃôsas so viele Umlaute

I tried Ascii-Encoding and a few other ones as the following source shows.

ASCIIEncoding encoder = new ASCIIEncoding();
Encoding enc = Encoding.GetEncoding(28591);

string response = enc.GetString(message, 0, bytesRead);

Which one will solve my problem?

+5  A: 

None of the following characters äüßÖ are ASCII.

You should be using the same encoding that they are in (probably UTF-8):

Encoding enc = new UTF8Encoding()
string response = enc.GetString(message, 0, bytesRead);

The codepage you are using (28591) is mapped to iso-8859-1, which includes these characters, however they are probably encoded as UTF-8 (or another unicode variant) but not iso-8859-1. You need to use the right encoding in order to get the correct encoded characters.

Oded
+6  A: 

I don't know anything at all about .NET, but I do know that this pattern of mojibake:

äüÃÃÂ

is characteristic of UTF-8 being misinterpreted as ISO-8859-1. So try processing your input as UTF-8.

Zack
Ok this helps but brings up another problem.See the question I'll post in a few minutes.
Hedge
A: 

In case you need 8-bit encoding, use ISO-8859-2 (or Latin 2) which supports German characters. Or, if you can, use some of UNICODE encodings like UTF-8. in the latter case rather let the encoder include the BOM (Byte Order Mark) at the start of the character stream, so that the apps reading or displaying your output can infer the encoding correctly.

Ondrej Tucny