On Fri, 3 May 2002 13:21:35 -0400, Marsh, Drew <[EMAIL PROTECTED]> wrote:

>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

I wish it were that simple, but it doesn't work.  It writes a question mark
char (ascii 0x3F) to the file.  I originally looked at the ASCIIEncoding
class, but the docs state that it only supports chars through 0x7F (7
bits).  Any other ideas?

Kyle

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