Table of Contents

Bodu.Text.Delimited.Writer Namespace

Package

Bodu.Text.Delimited.Writer

Purpose

Bodu.Text.Delimited.Writer is the emitting counterpart of Bodu.Text.Delimited.Reader in Bodu.Text.Delimited: a forward-only writer that produces RFC 4180 delimited text as UTF-8 into an IBufferWriter<byte> or a Stream. The DelimitedSerializer and the mutable DelimitedNode DOM (WriteTo) emit through it.

Key types

  • Utf8DelimitedWriter - the ref struct writer: WriteStartArray / WriteEndArray around the record set, WriteStartObject / WritePropertyName / WriteString / WriteEndObject for header-keyed records (or a nested array of WriteString for positional rows), plus Flush, Dispose, BytesCommitted, and BytesPending.
  • DelimitedWriterOptions - Delimiter, Quote, and NoHeader.

Example

using System.Buffers;
using Bodu.Text.Delimited.Writer;

var buffer = new ArrayBufferWriter<byte>();
var writer = new Utf8DelimitedWriter(buffer, new DelimitedWriterOptions { Delimiter = '\t' });

writer.WriteStartArray();
writer.WriteStartObject();
writer.WritePropertyName("symbol");
writer.WriteString("AAPL");
writer.WritePropertyName("qty");
writer.WriteString("10");
writer.WriteEndObject();
writer.WriteEndArray();
writer.Flush();   // "symbol\tqty\nAAPL\t10\n"

Notes

  • Header from the first record. The property names of the first object record become the header row; subsequent records contribute value rows only.
  • Minimal quoting. A field is quoted only when it contains the delimiter, the quote character, or a line break, with internal quotes doubled, so output round-trips through the reader.
  • Flush to commit. Bytes are staged until Flush (or Dispose); check BytesPending to see what is still buffered.
  • See also: the line-formats introduction and the delimited guide.

Structs

DelimitedWriterOptions

Provides configuration for a Utf8DelimitedWriter, controlling the delimiter, quote character, and whether a header row is emitted for object records.

Utf8DelimitedWriter

Provides a forward-only writer that emits delimited (RFC 4180 CSV/TSV) text as UTF-8 bytes to an IBufferWriter<T> or a Stream. The writer is a ref struct.