ControlChar

ControlChar class

Control characters often encountered in documents.

To learn more, visit the Working With Control Characters documentation article.

public static class ControlChar

Fields

NameDescription
static readonly CellEnd of a table cell or end of a table row character: “\x0007” or “\a”.
const CellCharEnd of a table cell or end of a table row character: (char)7 or “\a”.
static readonly ColumnBreakEnd of column character: “\x000e”.
const ColumnBreakCharEnd of column character: (char)14.
static readonly CrCarriage return character: “\x000d” or “\r”. Same as ParagraphBreak.
static readonly CrLfCarriage return followed by line feed character: “\x000d\x000a” or “\r\n”. Not used as such in Microsoft Word documents, but commonly used in text files for paragraph breaks.
const DefaultTextInputCharThis is the “o” character used as a default value in text input form fields.
const FieldEndCharEnd of MS Word field character: (char)21.
const FieldSeparatorCharField separator character separates field code from field value. Optional in some fields. Value: (char)20.
const FieldStartCharStart of MS Word field character: (char)19.
static readonly LfLine feed character: “\x000a” or “\n”. Same as LineFeed.
static readonly LineBreakLine break character: “\x000b” or “\v”.
const LineBreakCharLine break character: (char)11 or “\v”.
static readonly LineFeedLine feed character: “\x000a” or “\n”. Same as Lf.
const LineFeedCharLine feed character: (char)10 or “\n”.
const NonBreakingHyphenCharNon-breaking Hyphen in Microsoft Word is (char)30.
static readonly NonBreakingSpaceNon-breaking space character: “\x00a0”.
const NonBreakingSpaceCharNon-breaking space character: (char)160.
const OptionalHyphenCharOptional Hyphen in Microsoft Word is (char)31.
static readonly PageBreakPage break character: “\x000c” or “\f”. Note it has the same value as SectionBreak.
const PageBreakCharPage break character: (char)12 or “\f”.
static readonly ParagraphBreakEnd of paragraph character: “\x000d” or “\r”. Same as Cr
const ParagraphBreakCharEnd of paragraph character: (char)13 or “\r”.
static readonly SectionBreakEnd of section character: “\x000c” or “\f”. Note it has the same value as PageBreak.
const SectionBreakCharEnd of section character: (char)12 or “\f”.
const SpaceCharSpace character: (char)32.
static readonly TabTab character: “\x0009” or “\t”.
const TabCharTab character: (char)9 or “\t”.

Remarks

Provides both char and string versions of the same constants. For example: string LineBreak and char LineBreakChar have the same value.

Examples

Shows how to use control characters.

Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);

// Insert paragraphs with text with DocumentBuilder.
builder.Writeln("Hello world!");
builder.Writeln("Hello again!");

// Converting the document to text form reveals that control characters
// represent some of the document's structural elements, such as page breaks.
Assert.AreEqual($"Hello world!{ControlChar.Cr}" +
                $"Hello again!{ControlChar.Cr}" +
                ControlChar.PageBreak, doc.GetText());

// When converting a document to string form,
// we can omit some of the control characters with the Trim method.
Assert.AreEqual($"Hello world!{ControlChar.Cr}" +
                "Hello again!", doc.GetText().Trim());

See Also