Configuring the EDI writer settings
To control how EDI files are being generated, pass in either an EdifactWriterSettings or an X12WriterSettings object to the corresponding writer.
X12WriterSettings settings = new X12WriterSettings();
settings.AutoTrailers = true;
settings.Encoding = Encoding.UTF8;
settings.Postfix = Environment.NewLine;
settings.PreserveWhitespace = true;
settings.Separators = Separators.X12;
using (var writer = new X12Writer(stream, settings))
You can select any of the following settings:
- Encoding - this is the System.Encoding to use when writing to the output stream or file. UTF8 by default.
- PreserveWhitespace - this is to preserve white spaces in data elements initialized with blanks. False by default.
- Postfix - this is the postfix string to be applied at the end of each segment. Null by default.
- Separators - this is the set of separators to be used when generating the EDI document. It uses the default delimiter sets for X12 and EDIFACT when not explicitly set. The separators can be changed at run-time by using the overloads of Write(ISA isa) or Write(UNB unb).
- AutoTrailers - Whether to automatically apply trailers to groups and interchanges.