473,657 Members | 2,479 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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

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.Enc oding.ASCII);
swExport.WriteL ine("Ö");
swExport.Close( );
The output is a ?

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

Chris Auer

Nov 17 '05 #1
3 9681
Hi,

Chris Auer wrote:
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.Enc oding.GetEncodi ng("ISO-8859-1").
--
Chris Priede
Nov 17 '05 #2
Perfect. Thanks very much for the reply. You have made my day.

Thanks for all the help.

Nov 17 '05 #3
Chris Priede wrote:
Hi,

Chris Auer wrote:
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.


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,
--
http://www.joergjooss.de
mailto:ne****** **@joergjooss.d e
Nov 17 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
395
by: Mark | last post by:
Sorry about the last... Anyway, here's the question: I've been working on some C# routines to process strings in and out of various encodings. The hope is that I can just let the user type in the encoding they want and I'll do a pretty good job of converting. Basically, I take a string as input, write it to a byte array MemoryStream and then get the bytes of the conversion out. The oddity in my question is that when I use...
4
6697
by: I.Charitopoulos | last post by:
The reason I want to do so, is that I am sending to DOS and I am pretty certain that it will not work. Everything I've tried so far hasnt. In my test environment (Windows to Windows) this works perfectly, but not when sending to DOS: Private Function bytearray2string(ByVal input As Byte()) As String Dim output As String
1
9769
by: Emilio | last post by:
Question about Dim data As () = System.Text.Encoding.ASCII.GetBytes(message) Would it be the same to write: Dim data() As Byte = System.Text.Encoding.ASCII.GetBytes(message) ?
4
34149
by: George | last post by:
Hi, I am puzzled by the following and seeking some assistance to help me understand what happened. I have very limited encoding knowledge. Our SAP system writes out a text file which includes German characters. 1. When I use StreamReader(System.String filepath) without specifying an encoding method, the German characters such as Ă„ are lost when I do a ReadLine()
4
2034
by: A_StClaire_ | last post by:
hi, I am using the following code to download multiple file types from a server. .txt files transfer fine. however Word .doc files come through garbled and I don't know enough about encoding to understand why. the object 's' is a Mentalis.org component that, for all purposes here, is a System.Net.Socket. the line I commented out is one that hard-codes the encoding to 'ASCII' which I assume would only hurt me.
8
8832
by: > Adrian | last post by:
How do I use System.Text.Encoding.Default in conjunction with "append"? The objective being not to get into all sorts of problems with special ASCII characters like é etc. Many thanks, Adrian.
3
4916
by: =?Utf-8?B?RGFu?= | last post by:
When I use the following code I get "???" in place of the non-Ascii character. Is there any way to fix the conversion or do I have to write a function to search for "???" and replace with another character? Any help or suggestions would be greatly appreciated. Thanks Dan Dim plainText As String plainText = "tâ””he" Dim plainTextBytes As Byte()
4
1733
by: DR | last post by:
When using System.IO.FileStream, I write 8 bytes, then seek to the start of the file, does the 8 bytes get flushed on seek and the buffer become a readbuffer at that point instead of being a write buffer?
1
1914
by: Lloyd Dupont | last post by:
I think you could test that for your self, couldn't you! ;-) VS is a good hexa editor, if you want to do some hexa read of your file... "DR" <softwareengineer98037@yahoo.comwrote in message news:ufqDNzR8IHA.1200@TK2MSFTNGP04.phx.gbl...
0
8421
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8325
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8844
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8742
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8518
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
5643
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4173
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
2743
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1971
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.