runtime icon indicating copy to clipboard operation
runtime copied to clipboard

Add option on StreamWriter not to emit Byte Order Mark (BOM)

Open bpschoch opened this issue 11 years ago • 7 comments

Someone posted on CoreClr: https://github.com/dotnet/coreclr/issues/933 a requirement to have StreamWriter to optionally not emit BOM to the stream.

A possible solution is to either add a defaulted bool parameter to each/some of the constructors (bool emitBOM = True), or add a new enum e.g. StreamWriterOptions with EmitBOM as one of the enums and again having that enum as a defaulted parameter on each/some of the constructors.

There maybe an issue with binary compatibility so it might be better to add a new constructor with the bool/enum.'

Comments?

bpschoch avatar May 06 '15 18:05 bpschoch

Thanks I passed that on to original poster

bpschoch avatar May 06 '15 19:05 bpschoch

The issue with the original poster (From the asp.net project) is that encoder is passed to him (either with the flag on or off) but yet he needs to suppress the BOM regardless; see the link in my original post in to the coreclr post.

bpschoch avatar May 07 '15 00:05 bpschoch

You can create your custom wrapping Encoding class and return exactly what wrapped object with the only exception to return empty array in GetPreamble method.

krwq avatar May 07 '15 20:05 krwq

We're are not opposed but it seems if there is a workaround, it's lower priority. @bpschoch, please feel free to come up with a proposal.

terrajobst avatar Sep 29 '15 17:09 terrajobst

Assigning to @JeremyKuhne since he owns System.IO.

danmoseley avatar Sep 25 '16 14:09 danmoseley

There's a workaround, noone proposed another solution, closing. If anyone comes up with a proposal, feel free to reopen.

karelz avatar Oct 11 '16 21:10 karelz