Streamwriter class constructor - bug in default encoding? RRS feed

  • Question

  • Streamwriter class allows specification of the encoding to be used. For example if you use  

    System.IO.StreamWriter sw = new System.IO.StreamWriter(fs, Encoding.UTF8)

    The file created has the correct UTF8 BOM at the front of the file. If you do not specify the encoding the Streamwriter defaults to UFT8 but does not add the BOM to the front of the file. As a consequence downstream systems can (and do) misinterpret the encoding. As UTF8 is the stated default the correct BOM shoudl appear at the front of the file.

    Thursday, June 19, 2008 10:31 PM


All replies