Kyle Alons [mailto:[EMAIL PROTECTED]] wrote:

> What it writes to the file for the copyright character is
> UTF-8 encoding (two bytes).  What is the trick to get it to
> write the single character 169 (copyright char in codepage
> 1252)?  Thanks.

You need to go about creating your File and StreamWriter differently.
File.CreateText is basically a shortcut method that creates a StreamWriter
that uses UTF8Encoding only. To change the Encoding, you need to be more
explicit in your code. Like so:

<codeSnippet language="C#">
// Open the file stream
Stream fileStream = File.Create(@"c:\out.txt");

// Choose Encoding here when constructing the StreamWriter
StreamWriter writer = new StreamWriter(fileStream, Encoding.ASCII);

... writer will output ASCII data now ...
</codeSnippet>

HTH,
Drew

You can read messages from the DOTNET archive, unsubscribe from DOTNET, or
subscribe to other DevelopMentor lists at http://discuss.develop.com.

Reply via email to