public XmlUtf8RawTextWriter( Stream stream, Encoding encoding, XmlWriterSettings settings, bool closeOutput ) : this( settings, closeOutput ) {
Debug.Assert( stream != null && settings != null );
this.stream = stream;
this.encoding = encoding;
// the buffer is allocated will OVERFLOW in order to reduce checks when writing out constant size markup
bufBytes = new byte[ BUFSIZE + OVERFLOW ];
// Output UTF-8 byte order mark if Encoding object wants it
if ( !stream.CanSeek || stream.Position == 0 ) {
byte[] bom = encoding.GetPreamble();
if ( bom.Length != 0 ) {
Buffer.BlockCopy( bom, 0, bufBytes, 1, bom.Length );
bufPos += bom.Length;
textPos += bom.Length;
}
}
// Write the xml declaration
if ( settings.AutoXmlDeclaration ) {
WriteXmlDeclaration( standalone );
autoXmlDeclaration = true;
}
}