Description

The System.IO.StreamWriter class is designed for character output in a particular System.Text.Encoding, whereas subclasses of System.IO.Stream are designed for byte input and output.

System.IO.StreamWriter defaults to using an instance of System.Text.UTF8Encoding unless specified otherwise. This instance of System.Text.UTF8Encoding is constructed such that the System.Text.Encoding.GetPreamble method returns the Unicode byte order mark written in UTF-8. The preamble of the encoding is added to a stream when you are not appending to an existing stream. This means any text file you create with System.IO.StreamWriter has three byte order marks at its beginning. UTF-8 handles all Unicode characters correctly and gives consistent results ...

Get .NET Framework Standard Library Annotated Reference, Volume 1: Base Class Library and Extended Numerics Library now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.