Encoding Umlaut becomes ? when using System.Text.Encoding.ASCII

C

Chris Auer

I am trying to take in ASCII documents and convert them into ANSI for a
customer in Germany. But every file I process turns umlauts and other
german characters into something other then what it was.

Here is some real simple console code. It seems like umlauts are not in
ASCII, but they are.

StreamWriter swExport = new StreamWriter("C:\\MyDocuments\\In
Progress\\IIR\\OUT.txt",false,System.Text.Encoding.ASCII);
swExport.WriteLine("Ö");
swExport.Close();


The output is a ?

Has anyone worked with German characters and ASCII -> ANSI encoding.
Thanks for any help.

Chris Auer
 
C

Chris Priede

Hi,

Chris said:
Here is some real simple console code. It seems like umlauts are not
in ASCII, but they are.

No, they are not. ASCII only uses 7 bits and includes character values up
to 127; if you look at any character table, you will notice that there are
no accented characters in that range. They are instead contained in the
various (depending on language) 8-bit ISO code pages that are ASCII
compatible in the lower half, but define characters up to 255.

Try System.Text.Encoding.GetEncoding("ISO-8859-1").
 
C

Chris Auer

Perfect. Thanks very much for the reply. You have made my day.

Thanks for all the help.
 
J

Joerg Jooss

Chris said:
Hi,



No, they are not. ASCII only uses 7 bits and includes character
values up to 127; if you look at any character table, you will notice
that there are no accented characters in that range.

Just a note: There's an entire family of encodings (ISO-646-xx) that
replace certain characters within US-ASCII's 7 bit range for umlaut or
accented characters. These are even available on the Windows platform
and the .NET framework. See http://czyborra.com/charsets/iso646.html
for more information.

Thus, "7 bit" does not really imply "no umlauts", it's just that the
term "7 bit" has practically become a synonym for US-ASCII for all
practical purposes on UNIX and Windows platforms.

Cheers,
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top