StreamWriter as unicode

  • Thread starter Thread starter Lou
  • Start date Start date
L

Lou

How do i create a unicode stream writer?
Below is my code but its ascii...

private FileStream myStream;

//Create the Stream Writer, this is ascii

sw=new StreamWriter(myStream);

sw.WriteLine(Buffer + "\n");
 
Lou,

There is a constructor for the StreamWriter class which takes an
instance of the Encoding class (or rather, a class that derives from
Encoding). You can set this to whatever encoding is appropriate for the
underlying stream.

Hope this helps.
 
can you give me an example??

Nicholas Paldino said:
Lou,

There is a constructor for the StreamWriter class which takes an
instance of the Encoding class (or rather, a class that derives from
Encoding). You can set this to whatever encoding is appropriate for the
underlying stream.

Hope this helps.


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

Lou said:
How do i create a unicode stream writer?
Below is my code but its ascii...

private FileStream myStream;

//Create the Stream Writer, this is ascii

sw=new StreamWriter(myStream);

sw.WriteLine(Buffer + "\n");
 
Lou,

If your underlying stream uses Ascii encoding, you can change the
constructor to this:

// Create the StreamWriter.
sw = new StreamWriter(myStream, Encoding.ASCII);

--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)




Lou said:
can you give me an example??

message news:%[email protected]...
Lou,

There is a constructor for the StreamWriter class which takes an
instance of the Encoding class (or rather, a class that derives from
Encoding). You can set this to whatever encoding is appropriate for the
underlying stream.

Hope this helps.


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

Lou said:
How do i create a unicode stream writer?
Below is my code but its ascii...

private FileStream myStream;

//Create the Stream Writer, this is ascii

sw=new StreamWriter(myStream);

sw.WriteLine(Buffer + "\n");
 
Back
Top