Groups | Blog | Home
all groups > c# > december 2007 >

c# : Encoding Text für writing a textfile



Peter Duniho
12/7/2007 1:47:48 PM
On Fri, 07 Dec 2007 13:24:05 -0800, Martin Fischer <NOSPAM@nowhere.com>
[quoted text, click to view]

What "type of ASCII"? There's only one ASCII. How do you set
System.Text.Encoding.Default, given that it's a read-only property?

As far as the StreamWriter goes, you can specify an encoding via the
constructor when you instantiate the StreamWriter.

RobertK
12/7/2007 3:29:15 PM
Do you mean you want the file written in plain ASCII?

This appears to produce a simple ASCII text file:

FileStream FS = new FileStream("d:\\myfile.txt",FileMode.OpenOrCreate);
StreamWriter SW = new StreamWriter(FS, Encoding.ASCII);


Martin Fischer
12/7/2007 10:24:05 PM
Hi everybody,

i have a problem with teh StreamWriter Object. I want to force the Stream to
write an ANSI-text. For reading from an filestream i can define the type of
ASCI by setting
System.Text.Encoding.Default.

What about Wrting Textdate ? The result seems to be UTF7 -Charset, but no
real ANSI.

Any hint for me ?

Martin

Peter Duniho
12/7/2007 11:41:26 PM
On Fri, 07 Dec 2007 22:45:10 -0800, Martin Fischer <NOSPAM@nowhere.com>
[quoted text, click to view]

Why there's no StreamWriter(String, Encoding) overload, I don't know. But
there are other overloads for the StreamWriter constructor that take a
file name and an encoding. For example:

http://msdn2.microsoft.com/en-us/library/f5f5x7kt.aspx

Martin Fischer
12/8/2007 7:45:10 AM
Thanks a lot. Thats what i ve been searching for ...

I have been trying to create a StreamWriter-Object without creating a
previos filestram, and in this structure i didnt find a way to specify the
Encodeng ....

Wish you a nice weekend.

Martin


"RobertK" <robertk@xmission.com> schrieb im Newsbeitrag
news:929BAA78-543E-420C-A0E6-0C9CC33F4CB1@microsoft.com...
[quoted text, click to view]

AddThis Social Bookmark Button