bugDotGNU Portable.NET - Bugs: bug #2409, StreamWriter places byte order...

 
 

You are not allowed to post comments on this tracker with your current authentication level.

bug #2409: StreamWriter places byte order mark with default UTF8 encoding

Submitted by:  Marcus Urban <mathpup>
Submitted on:  Tue 28 Jan 2003 01:35:05 AM UTC  
 
Category: NoneSeverity: 3 - Normal
Item Group: NoneStatus: Fixed
Privacy: PublicAssigned to: None
Open/Closed: Closed

Tue 28 Jan 2003 05:54:12 AM UTC, comment #1:

Fix applied 28 Jan 2003 - should hopefully now be
consistent with Rotor.

Rhys Weatherley <rweather>
Project Administrator
Tue 28 Jan 2003 01:35:05 AM UTC, original submission:

This appears to be one of the cases where the ECMA spec (from ECMA's website) contradicts itself. In the general description of StreamWriter, it states

"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."

Unfortunately, the sections for each constructor of StreamWriter contradict this sharply. Taken from the constructor that accepts a single string:

"This constructor initializes the System.IO.StreamWriter.Encoding property to a System.Text.UTF8Encoding whose System.Text.Encoding.GetPreamble method returns an empty byte array."

The other constructors have similar wording.

I tested the behavior against Rotor, and Rotor does not place the byte order mark by default, so the "correct" behavior seems to be that given in the constructors.

I'm attaching a test. On Rotor, there are no byte order markers present. On Pnet, there are.

Marcus Urban <mathpup>

 

Attached Files
file #263:  writer.cs added by mathpup (176B - text/x-csharp)

 

Depends on the following items: None found

Items that depend on this one: None found

 

CC list is empty

 

Do you think this task is very important?
If so, you can click here to add your encouragement to it.
This task has 0 encouragements so far.

Only logged-in users can vote.

 

Please enter the title of George Orwell's famous dystopian book (it's a date):

 

 

Follow 2 latest changes.

Date Changed By Updated Field Previous Value => Replaced By
Tue 28 Jan 2003 05:54:12 AM UTCrweatherStatusNone=>(Error - Not Found)
  Open/ClosedOpen=>(Error - Not Found)

Back to the top


Powered by Savane 3.1-cleanup1