search/mag_sel search/close

Control characters often encountered in documents.

Examples

Shows how to use control characters.

auto doc = MakeObject<Document>();
auto builder = MakeObject<DocumentBuilder>(doc);
// Insert paragraphs with text with DocumentBuilder.
builder->Writeln(u"Hello world!");
builder->Writeln(u"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_EQ(String::Format(u"Hello world!{0}", ControlChar::Cr()) + String::Format(u"Hello again!{0}", 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_EQ(String::Format(u"Hello world!{0}", ControlChar::Cr()) + u"Hello again!", doc->GetText().Trim());

#include <Aspose.Words.Cpp/ControlChar.h>

Public Member Functions

 ControlChar ()=delete
 

Static Public Member Functions

static StringCell ()
 End of a table cell or end of a table row character: "\x0007" or "\a". More...
 
static StringColumnBreak ()
 End of column character: "\x000e". More...
 
static StringCr ()
 Carriage return character: "\x000d" or "\r". Same as ParagraphBreak. More...
 
static StringCrLf ()
 Carriage 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. More...
 
static StringLf ()
 Line feed character: "\x000a" or "\n". Same as LineFeed. More...
 
static StringLineBreak ()
 Line break character: "\x000b" or "\v". More...
 
static StringLineFeed ()
 Line feed character: "\x000a" or "\n". Same as Lf. More...
 
static StringNonBreakingSpace ()
 Non-breaking space character: "\x00a0". More...
 
static StringPageBreak ()
 Page break character: "\x000c" or "\f". Note it has the same value as SectionBreak. More...
 
static StringParagraphBreak ()
 End of paragraph character: "\x000d" or "\r". Same as Cr More...
 
static StringSectionBreak ()
 End of section character: "\x000c" or "\f". Note it has the same value as PageBreak. More...
 
static StringTab ()
 Tab character: "\x0009" or "\t". More...
 

Static Public Attributes

static constexpr char16_t CellChar = (char16_t)7
 End of a table cell or end of a table row character: (char)7 or "\a". More...
 
static constexpr char16_t ColumnBreakChar = (char16_t)14
 End of column character: (char)14. More...
 
static constexpr char16_t DefaultTextInputChar = u'\x2002'
 This is the "o" character used as a default value in text input form fields. More...
 
static constexpr char16_t FieldEndChar = (char16_t)21
 End of MS Word field character: (char)21. More...
 
static constexpr char16_t FieldSeparatorChar = (char16_t)20
 Field separator character separates field code from field value. Optional in some fields. Value: (char)20. More...
 
static constexpr char16_t FieldStartChar = (char16_t)19
 Start of MS Word field character: (char)19. More...
 
static constexpr char16_t LineBreakChar = (char16_t)11
 Line break character: (char)11 or "\v". More...
 
static constexpr char16_t LineFeedChar = (char16_t)10
 Line feed character: (char)10 or "\n". More...
 
static constexpr char16_t NonBreakingHyphenChar = (char16_t)30
 Nonbreaking Hyphen in Microsoft Word is (char)30. More...
 
static constexpr char16_t NonBreakingSpaceChar = u'\x00a0'
 Non-breaking space character: (char)160. More...
 
static constexpr char16_t OptionalHyphenChar = (char16_t)31
 Optional Hyphen in Microsoft Word is (char)31. More...
 
static constexpr char16_t PageBreakChar = (char16_t)12
 Page break character: (char)12 or "\f". More...
 
static constexpr char16_t ParagraphBreakChar = (char16_t)13
 End of paragraph character: (char)13 or "\r". More...
 
static constexpr char16_t SectionBreakChar = (char16_t)12
 End of section character: (char)12 or "\f". More...
 
static constexpr char16_t SpaceChar = (char16_t)32
 Space character: (char)32. More...
 
static constexpr char16_t TabChar = (char16_t)9
 Tab character: (char)9 or "\t". More...
 

Constructor & Destructor Documentation

◆ ControlChar()

Aspose::Words::ControlChar::ControlChar ( )
delete

Member Function Documentation

◆ Cell()

static System::String& Aspose::Words::ControlChar::Cell ( )
static

End of a table cell or end of a table row character: "\x0007" or "\a".

Examples

Shows how to add various control characters to a document.

auto doc = MakeObject<Document>();
auto builder = MakeObject<DocumentBuilder>(doc);
// Add a regular space.
builder->Write(String(u"Before space.") + ControlChar::SpaceChar + u"After space.");
// Add an NBSP, which is a non-breaking space.
// Unlike the regular space, this space cannot have an automatic line break at its position.
builder->Write(String(u"Before space.") + ControlChar::NonBreakingSpace() + u"After space.");
// Add a tab character.
builder->Write(String(u"Before tab.") + ControlChar::Tab() + u"After tab.");
// Add a line break.
builder->Write(String(u"Before line break.") + ControlChar::LineBreak() + u"After line break.");
// Add a new line and starts a new paragraph.
ASSERT_EQ(1, doc->get_FirstSection()->get_Body()->GetChildNodes(NodeType::Paragraph, true)->get_Count());
builder->Write(String(u"Before line feed.") + ControlChar::LineFeed() + u"After line feed.");
ASSERT_EQ(2, doc->get_FirstSection()->get_Body()->GetChildNodes(NodeType::Paragraph, true)->get_Count());
// The line feed character has two versions.
// Carriage returns and line feeds can be represented together by one character.
// Add a paragraph break, which will start a new paragraph.
builder->Write(String(u"Before paragraph break.") + ControlChar::ParagraphBreak() + u"After paragraph break.");
ASSERT_EQ(3, doc->get_FirstSection()->get_Body()->GetChildNodes(NodeType::Paragraph, true)->get_Count());
// Add a section break. This does not make a new section or paragraph.
ASSERT_EQ(1, doc->get_Sections()->get_Count());
builder->Write(String(u"Before section break.") + ControlChar::SectionBreak() + u"After section break.");
ASSERT_EQ(1, doc->get_Sections()->get_Count());
// Add a page break.
builder->Write(String(u"Before page break.") + ControlChar::PageBreak() + u"After page break.");
// A page break is the same value as a section break.
// Insert a new section, and then set its column count to two.
doc->AppendChild(MakeObject<Section>(doc));
builder->MoveToSection(1);
builder->get_CurrentSection()->get_PageSetup()->get_TextColumns()->SetCount(2);
// We can use a control character to mark the point where text moves to the next column.
builder->Write(String(u"Text at end of column 1.") + ControlChar::ColumnBreak() + u"Text at beginning of column 2.");
doc->Save(ArtifactsDir + u"ControlChar.InsertControlChars.docx");
// There are char and string counterparts for most characters.

◆ ColumnBreak()

static System::String& Aspose::Words::ControlChar::ColumnBreak ( )
static

End of column character: "\x000e".

Examples

Shows how to add various control characters to a document.

auto doc = MakeObject<Document>();
auto builder = MakeObject<DocumentBuilder>(doc);
// Add a regular space.
builder->Write(String(u"Before space.") + ControlChar::SpaceChar + u"After space.");
// Add an NBSP, which is a non-breaking space.
// Unlike the regular space, this space cannot have an automatic line break at its position.
builder->Write(String(u"Before space.") + ControlChar::NonBreakingSpace() + u"After space.");
// Add a tab character.
builder->Write(String(u"Before tab.") + ControlChar::Tab() + u"After tab.");
// Add a line break.
builder->Write(String(u"Before line break.") + ControlChar::LineBreak() + u"After line break.");
// Add a new line and starts a new paragraph.
ASSERT_EQ(1, doc->get_FirstSection()->get_Body()->GetChildNodes(NodeType::Paragraph, true)->get_Count());
builder->Write(String(u"Before line feed.") + ControlChar::LineFeed() + u"After line feed.");
ASSERT_EQ(2, doc->get_FirstSection()->get_Body()->GetChildNodes(NodeType::Paragraph, true)->get_Count());
// The line feed character has two versions.
// Carriage returns and line feeds can be represented together by one character.
// Add a paragraph break, which will start a new paragraph.
builder->Write(String(u"Before paragraph break.") + ControlChar::ParagraphBreak() + u"After paragraph break.");
ASSERT_EQ(3, doc->get_FirstSection()->get_Body()->GetChildNodes(NodeType::Paragraph, true)->get_Count());
// Add a section break. This does not make a new section or paragraph.
ASSERT_EQ(1, doc->get_Sections()->get_Count());
builder->Write(String(u"Before section break.") + ControlChar::SectionBreak() + u"After section break.");
ASSERT_EQ(1, doc->get_Sections()->get_Count());
// Add a page break.
builder->Write(String(u"Before page break.") + ControlChar::PageBreak() + u"After page break.");
// A page break is the same value as a section break.
// Insert a new section, and then set its column count to two.
doc->AppendChild(MakeObject<Section>(doc));
builder->MoveToSection(1);
builder->get_CurrentSection()->get_PageSetup()->get_TextColumns()->SetCount(2);
// We can use a control character to mark the point where text moves to the next column.
builder->Write(String(u"Text at end of column 1.") + ControlChar::ColumnBreak() + u"Text at beginning of column 2.");
doc->Save(ArtifactsDir + u"ControlChar.InsertControlChars.docx");
// There are char and string counterparts for most characters.

◆ Cr()

static System::String& Aspose::Words::ControlChar::Cr ( )
static

Carriage return character: "\x000d" or "\r". Same as ParagraphBreak.

Examples

Shows how to use control characters.

auto doc = MakeObject<Document>();
auto builder = MakeObject<DocumentBuilder>(doc);
// Insert paragraphs with text with DocumentBuilder.
builder->Writeln(u"Hello world!");
builder->Writeln(u"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_EQ(String::Format(u"Hello world!{0}", ControlChar::Cr()) + String::Format(u"Hello again!{0}", 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_EQ(String::Format(u"Hello world!{0}", ControlChar::Cr()) + u"Hello again!", doc->GetText().Trim());

◆ CrLf()

static System::String& Aspose::Words::ControlChar::CrLf ( )
static

Carriage 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.

Examples

Shows how to add various control characters to a document.

auto doc = MakeObject<Document>();
auto builder = MakeObject<DocumentBuilder>(doc);
// Add a regular space.
builder->Write(String(u"Before space.") + ControlChar::SpaceChar + u"After space.");
// Add an NBSP, which is a non-breaking space.
// Unlike the regular space, this space cannot have an automatic line break at its position.
builder->Write(String(u"Before space.") + ControlChar::NonBreakingSpace() + u"After space.");
// Add a tab character.
builder->Write(String(u"Before tab.") + ControlChar::Tab() + u"After tab.");
// Add a line break.
builder->Write(String(u"Before line break.") + ControlChar::LineBreak() + u"After line break.");
// Add a new line and starts a new paragraph.
ASSERT_EQ(1, doc->get_FirstSection()->get_Body()->GetChildNodes(NodeType::Paragraph, true)->get_Count());
builder->Write(String(u"Before line feed.") + ControlChar::LineFeed() + u"After line feed.");
ASSERT_EQ(2, doc->get_FirstSection()->get_Body()->GetChildNodes(NodeType::Paragraph, true)->get_Count());
// The line feed character has two versions.
// Carriage returns and line feeds can be represented together by one character.
// Add a paragraph break, which will start a new paragraph.
builder->Write(String(u"Before paragraph break.") + ControlChar::ParagraphBreak() + u"After paragraph break.");
ASSERT_EQ(3, doc->get_FirstSection()->get_Body()->GetChildNodes(NodeType::Paragraph, true)->get_Count());
// Add a section break. This does not make a new section or paragraph.
ASSERT_EQ(1, doc->get_Sections()->get_Count());
builder->Write(String(u"Before section break.") + ControlChar::SectionBreak() + u"After section break.");
ASSERT_EQ(1, doc->get_Sections()->get_Count());
// Add a page break.
builder->Write(String(u"Before page break.") + ControlChar::PageBreak() + u"After page break.");
// A page break is the same value as a section break.
// Insert a new section, and then set its column count to two.
doc->AppendChild(MakeObject<Section>(doc));
builder->MoveToSection(1);
builder->get_CurrentSection()->get_PageSetup()->get_TextColumns()->SetCount(2);
// We can use a control character to mark the point where text moves to the next column.
builder->Write(String(u"Text at end of column 1.") + ControlChar::ColumnBreak() + u"Text at beginning of column 2.");
doc->Save(ArtifactsDir + u"ControlChar.InsertControlChars.docx");
// There are char and string counterparts for most characters.

◆ Lf()

static System::String& Aspose::Words::ControlChar::Lf ( )
static

Line feed character: "\x000a" or "\n". Same as LineFeed.

Examples

Shows how to add various control characters to a document.

auto doc = MakeObject<Document>();
auto builder = MakeObject<DocumentBuilder>(doc);
// Add a regular space.
builder->Write(String(u"Before space.") + ControlChar::SpaceChar + u"After space.");
// Add an NBSP, which is a non-breaking space.
// Unlike the regular space, this space cannot have an automatic line break at its position.
builder->Write(String(u"Before space.") + ControlChar::NonBreakingSpace() + u"After space.");
// Add a tab character.
builder->Write(String(u"Before tab.") + ControlChar::Tab() + u"After tab.");
// Add a line break.
builder->Write(String(u"Before line break.") + ControlChar::LineBreak() + u"After line break.");
// Add a new line and starts a new paragraph.
ASSERT_EQ(1, doc->get_FirstSection()->get_Body()->GetChildNodes(NodeType::Paragraph, true)->get_Count());
builder->Write(String(u"Before line feed.") + ControlChar::LineFeed() + u"After line feed.");
ASSERT_EQ(2, doc->get_FirstSection()->get_Body()->GetChildNodes(NodeType::Paragraph, true)->get_Count());
// The line feed character has two versions.
// Carriage returns and line feeds can be represented together by one character.
// Add a paragraph break, which will start a new paragraph.
builder->Write(String(u"Before paragraph break.") + ControlChar::ParagraphBreak() + u"After paragraph break.");
ASSERT_EQ(3, doc->get_FirstSection()->get_Body()->GetChildNodes(NodeType::Paragraph, true)->get_Count());
// Add a section break. This does not make a new section or paragraph.
ASSERT_EQ(1, doc->get_Sections()->get_Count());
builder->Write(String(u"Before section break.") + ControlChar::SectionBreak() + u"After section break.");
ASSERT_EQ(1, doc->get_Sections()->get_Count());
// Add a page break.
builder->Write(String(u"Before page break.") + ControlChar::PageBreak() + u"After page break.");
// A page break is the same value as a section break.
// Insert a new section, and then set its column count to two.
doc->AppendChild(MakeObject<Section>(doc));
builder->MoveToSection(1);
builder->get_CurrentSection()->get_PageSetup()->get_TextColumns()->SetCount(2);
// We can use a control character to mark the point where text moves to the next column.
builder->Write(String(u"Text at end of column 1.") + ControlChar::ColumnBreak() + u"Text at beginning of column 2.");
doc->Save(ArtifactsDir + u"ControlChar.InsertControlChars.docx");
// There are char and string counterparts for most characters.

◆ LineBreak()

static System::String& Aspose::Words::ControlChar::LineBreak ( )
static

Line break character: "\x000b" or "\v".

Examples

Shows how to add various control characters to a document.

auto doc = MakeObject<Document>();
auto builder = MakeObject<DocumentBuilder>(doc);
// Add a regular space.
builder->Write(String(u"Before space.") + ControlChar::SpaceChar + u"After space.");
// Add an NBSP, which is a non-breaking space.
// Unlike the regular space, this space cannot have an automatic line break at its position.
builder->Write(String(u"Before space.") + ControlChar::NonBreakingSpace() + u"After space.");
// Add a tab character.
builder->Write(String(u"Before tab.") + ControlChar::Tab() + u"After tab.");
// Add a line break.
builder->Write(String(u"Before line break.") + ControlChar::LineBreak() + u"After line break.");
// Add a new line and starts a new paragraph.
ASSERT_EQ(1, doc->get_FirstSection()->get_Body()->GetChildNodes(NodeType::Paragraph, true)->get_Count());
builder->Write(String(u"Before line feed.") + ControlChar::LineFeed() + u"After line feed.");
ASSERT_EQ(2, doc->get_FirstSection()->get_Body()->GetChildNodes(NodeType::Paragraph, true)->get_Count());
// The line feed character has two versions.
// Carriage returns and line feeds can be represented together by one character.
// Add a paragraph break, which will start a new paragraph.
builder->Write(String(u"Before paragraph break.") + ControlChar::ParagraphBreak() + u"After paragraph break.");
ASSERT_EQ(3, doc->get_FirstSection()->get_Body()->GetChildNodes(NodeType::Paragraph, true)->get_Count());
// Add a section break. This does not make a new section or paragraph.
ASSERT_EQ(1, doc->get_Sections()->get_Count());
builder->Write(String(u"Before section break.") + ControlChar::SectionBreak() + u"After section break.");
ASSERT_EQ(1, doc->get_Sections()->get_Count());
// Add a page break.
builder->Write(String(u"Before page break.") + ControlChar::PageBreak() + u"After page break.");
// A page break is the same value as a section break.
// Insert a new section, and then set its column count to two.
doc->AppendChild(MakeObject<Section>(doc));
builder->MoveToSection(1);
builder->get_CurrentSection()->get_PageSetup()->get_TextColumns()->SetCount(2);
// We can use a control character to mark the point where text moves to the next column.
builder->Write(String(u"Text at end of column 1.") + ControlChar::ColumnBreak() + u"Text at beginning of column 2.");
doc->Save(ArtifactsDir + u"ControlChar.InsertControlChars.docx");
// There are char and string counterparts for most characters.

◆ LineFeed()

static System::String& Aspose::Words::ControlChar::LineFeed ( )
static

Line feed character: "\x000a" or "\n". Same as Lf.

Examples

Shows how to add various control characters to a document.

auto doc = MakeObject<Document>();
auto builder = MakeObject<DocumentBuilder>(doc);
// Add a regular space.
builder->Write(String(u"Before space.") + ControlChar::SpaceChar + u"After space.");
// Add an NBSP, which is a non-breaking space.
// Unlike the regular space, this space cannot have an automatic line break at its position.
builder->Write(String(u"Before space.") + ControlChar::NonBreakingSpace() + u"After space.");
// Add a tab character.
builder->Write(String(u"Before tab.") + ControlChar::Tab() + u"After tab.");
// Add a line break.
builder->Write(String(u"Before line break.") + ControlChar::LineBreak() + u"After line break.");
// Add a new line and starts a new paragraph.
ASSERT_EQ(1, doc->get_FirstSection()->get_Body()->GetChildNodes(NodeType::Paragraph, true)->get_Count());
builder->Write(String(u"Before line feed.") + ControlChar::LineFeed() + u"After line feed.");
ASSERT_EQ(2, doc->get_FirstSection()->get_Body()->GetChildNodes(NodeType::Paragraph, true)->get_Count());
// The line feed character has two versions.
// Carriage returns and line feeds can be represented together by one character.
// Add a paragraph break, which will start a new paragraph.
builder->Write(String(u"Before paragraph break.") + ControlChar::ParagraphBreak() + u"After paragraph break.");
ASSERT_EQ(3, doc->get_FirstSection()->get_Body()->GetChildNodes(NodeType::Paragraph, true)->get_Count());
// Add a section break. This does not make a new section or paragraph.
ASSERT_EQ(1, doc->get_Sections()->get_Count());
builder->Write(String(u"Before section break.") + ControlChar::SectionBreak() + u"After section break.");
ASSERT_EQ(1, doc->get_Sections()->get_Count());
// Add a page break.
builder->Write(String(u"Before page break.") + ControlChar::PageBreak() + u"After page break.");
// A page break is the same value as a section break.
// Insert a new section, and then set its column count to two.
doc->AppendChild(MakeObject<Section>(doc));
builder->MoveToSection(1);
builder->get_CurrentSection()->get_PageSetup()->get_TextColumns()->SetCount(2);
// We can use a control character to mark the point where text moves to the next column.
builder->Write(String(u"Text at end of column 1.") + ControlChar::ColumnBreak() + u"Text at beginning of column 2.");
doc->Save(ArtifactsDir + u"ControlChar.InsertControlChars.docx");
// There are char and string counterparts for most characters.

◆ NonBreakingSpace()

static System::String& Aspose::Words::ControlChar::NonBreakingSpace ( )
static

Non-breaking space character: "\x00a0".

Examples

Shows how to add various control characters to a document.

auto doc = MakeObject<Document>();
auto builder = MakeObject<DocumentBuilder>(doc);
// Add a regular space.
builder->Write(String(u"Before space.") + ControlChar::SpaceChar + u"After space.");
// Add an NBSP, which is a non-breaking space.
// Unlike the regular space, this space cannot have an automatic line break at its position.
builder->Write(String(u"Before space.") + ControlChar::NonBreakingSpace() + u"After space.");
// Add a tab character.
builder->Write(String(u"Before tab.") + ControlChar::Tab() + u"After tab.");
// Add a line break.
builder->Write(String(u"Before line break.") + ControlChar::LineBreak() + u"After line break.");
// Add a new line and starts a new paragraph.
ASSERT_EQ(1, doc->get_FirstSection()->get_Body()->GetChildNodes(NodeType::Paragraph, true)->get_Count());
builder->Write(String(u"Before line feed.") + ControlChar::LineFeed() + u"After line feed.");
ASSERT_EQ(2, doc->get_FirstSection()->get_Body()->GetChildNodes(NodeType::Paragraph, true)->get_Count());
// The line feed character has two versions.
// Carriage returns and line feeds can be represented together by one character.
// Add a paragraph break, which will start a new paragraph.
builder->Write(String(u"Before paragraph break.") + ControlChar::ParagraphBreak() + u"After paragraph break.");
ASSERT_EQ(3, doc->get_FirstSection()->get_Body()->GetChildNodes(NodeType::Paragraph, true)->get_Count());
// Add a section break. This does not make a new section or paragraph.
ASSERT_EQ(1, doc->get_Sections()->get_Count());
builder->Write(String(u"Before section break.") + ControlChar::SectionBreak() + u"After section break.");
ASSERT_EQ(1, doc->get_Sections()->get_Count());
// Add a page break.
builder->Write(String(u"Before page break.") + ControlChar::PageBreak() + u"After page break.");
// A page break is the same value as a section break.
// Insert a new section, and then set its column count to two.
doc->AppendChild(MakeObject<Section>(doc));
builder->MoveToSection(1);
builder->get_CurrentSection()->get_PageSetup()->get_TextColumns()->SetCount(2);
// We can use a control character to mark the point where text moves to the next column.
builder->Write(String(u"Text at end of column 1.") + ControlChar::ColumnBreak() + u"Text at beginning of column 2.");
doc->Save(ArtifactsDir + u"ControlChar.InsertControlChars.docx");
// There are char and string counterparts for most characters.

◆ PageBreak()

static System::String& Aspose::Words::ControlChar::PageBreak ( )
static

Page break character: "\x000c" or "\f". Note it has the same value as SectionBreak.

Examples

Shows how to add various control characters to a document.

auto doc = MakeObject<Document>();
auto builder = MakeObject<DocumentBuilder>(doc);
// Add a regular space.
builder->Write(String(u"Before space.") + ControlChar::SpaceChar + u"After space.");
// Add an NBSP, which is a non-breaking space.
// Unlike the regular space, this space cannot have an automatic line break at its position.
builder->Write(String(u"Before space.") + ControlChar::NonBreakingSpace() + u"After space.");
// Add a tab character.
builder->Write(String(u"Before tab.") + ControlChar::Tab() + u"After tab.");
// Add a line break.
builder->Write(String(u"Before line break.") + ControlChar::LineBreak() + u"After line break.");
// Add a new line and starts a new paragraph.
ASSERT_EQ(1, doc->get_FirstSection()->get_Body()->GetChildNodes(NodeType::Paragraph, true)->get_Count());
builder->Write(String(u"Before line feed.") + ControlChar::LineFeed() + u"After line feed.");
ASSERT_EQ(2, doc->get_FirstSection()->get_Body()->GetChildNodes(NodeType::Paragraph, true)->get_Count());
// The line feed character has two versions.
// Carriage returns and line feeds can be represented together by one character.
// Add a paragraph break, which will start a new paragraph.
builder->Write(String(u"Before paragraph break.") + ControlChar::ParagraphBreak() + u"After paragraph break.");
ASSERT_EQ(3, doc->get_FirstSection()->get_Body()->GetChildNodes(NodeType::Paragraph, true)->get_Count());
// Add a section break. This does not make a new section or paragraph.
ASSERT_EQ(1, doc->get_Sections()->get_Count());
builder->Write(String(u"Before section break.") + ControlChar::SectionBreak() + u"After section break.");
ASSERT_EQ(1, doc->get_Sections()->get_Count());
// Add a page break.
builder->Write(String(u"Before page break.") + ControlChar::PageBreak() + u"After page break.");
// A page break is the same value as a section break.
// Insert a new section, and then set its column count to two.
doc->AppendChild(MakeObject<Section>(doc));
builder->MoveToSection(1);
builder->get_CurrentSection()->get_PageSetup()->get_TextColumns()->SetCount(2);
// We can use a control character to mark the point where text moves to the next column.
builder->Write(String(u"Text at end of column 1.") + ControlChar::ColumnBreak() + u"Text at beginning of column 2.");
doc->Save(ArtifactsDir + u"ControlChar.InsertControlChars.docx");
// There are char and string counterparts for most characters.

◆ ParagraphBreak()

static System::String& Aspose::Words::ControlChar::ParagraphBreak ( )
static

End of paragraph character: "\x000d" or "\r". Same as Cr

Examples

Shows how to add various control characters to a document.

auto doc = MakeObject<Document>();
auto builder = MakeObject<DocumentBuilder>(doc);
// Add a regular space.
builder->Write(String(u"Before space.") + ControlChar::SpaceChar + u"After space.");
// Add an NBSP, which is a non-breaking space.
// Unlike the regular space, this space cannot have an automatic line break at its position.
builder->Write(String(u"Before space.") + ControlChar::NonBreakingSpace() + u"After space.");
// Add a tab character.
builder->Write(String(u"Before tab.") + ControlChar::Tab() + u"After tab.");
// Add a line break.
builder->Write(String(u"Before line break.") + ControlChar::LineBreak() + u"After line break.");
// Add a new line and starts a new paragraph.
ASSERT_EQ(1, doc->get_FirstSection()->get_Body()->GetChildNodes(NodeType::Paragraph, true)->get_Count());
builder->Write(String(u"Before line feed.") + ControlChar::LineFeed() + u"After line feed.");
ASSERT_EQ(2, doc->get_FirstSection()->get_Body()->GetChildNodes(NodeType::Paragraph, true)->get_Count());
// The line feed character has two versions.
// Carriage returns and line feeds can be represented together by one character.
// Add a paragraph break, which will start a new paragraph.
builder->Write(String(u"Before paragraph break.") + ControlChar::ParagraphBreak() + u"After paragraph break.");
ASSERT_EQ(3, doc->get_FirstSection()->get_Body()->GetChildNodes(NodeType::Paragraph, true)->get_Count());
// Add a section break. This does not make a new section or paragraph.
ASSERT_EQ(1, doc->get_Sections()->get_Count());
builder->Write(String(u"Before section break.") + ControlChar::SectionBreak() + u"After section break.");
ASSERT_EQ(1, doc->get_Sections()->get_Count());
// Add a page break.
builder->Write(String(u"Before page break.") + ControlChar::PageBreak() + u"After page break.");
// A page break is the same value as a section break.
// Insert a new section, and then set its column count to two.
doc->AppendChild(MakeObject<Section>(doc));
builder->MoveToSection(1);
builder->get_CurrentSection()->get_PageSetup()->get_TextColumns()->SetCount(2);
// We can use a control character to mark the point where text moves to the next column.
builder->Write(String(u"Text at end of column 1.") + ControlChar::ColumnBreak() + u"Text at beginning of column 2.");
doc->Save(ArtifactsDir + u"ControlChar.InsertControlChars.docx");
// There are char and string counterparts for most characters.

◆ SectionBreak()

static System::String& Aspose::Words::ControlChar::SectionBreak ( )
static

End of section character: "\x000c" or "\f". Note it has the same value as PageBreak.

Examples

Shows how to add various control characters to a document.

auto doc = MakeObject<Document>();
auto builder = MakeObject<DocumentBuilder>(doc);
// Add a regular space.
builder->Write(String(u"Before space.") + ControlChar::SpaceChar + u"After space.");
// Add an NBSP, which is a non-breaking space.
// Unlike the regular space, this space cannot have an automatic line break at its position.
builder->Write(String(u"Before space.") + ControlChar::NonBreakingSpace() + u"After space.");
// Add a tab character.
builder->Write(String(u"Before tab.") + ControlChar::Tab() + u"After tab.");
// Add a line break.
builder->Write(String(u"Before line break.") + ControlChar::LineBreak() + u"After line break.");
// Add a new line and starts a new paragraph.
ASSERT_EQ(1, doc->get_FirstSection()->get_Body()->GetChildNodes(NodeType::Paragraph, true)->get_Count());
builder->Write(String(u"Before line feed.") + ControlChar::LineFeed() + u"After line feed.");
ASSERT_EQ(2, doc->get_FirstSection()->get_Body()->GetChildNodes(NodeType::Paragraph, true)->get_Count());
// The line feed character has two versions.
// Carriage returns and line feeds can be represented together by one character.
// Add a paragraph break, which will start a new paragraph.
builder->Write(String(u"Before paragraph break.") + ControlChar::ParagraphBreak() + u"After paragraph break.");
ASSERT_EQ(3, doc->get_FirstSection()->get_Body()->GetChildNodes(NodeType::Paragraph, true)->get_Count());
// Add a section break. This does not make a new section or paragraph.
ASSERT_EQ(1, doc->get_Sections()->get_Count());
builder->Write(String(u"Before section break.") + ControlChar::SectionBreak() + u"After section break.");
ASSERT_EQ(1, doc->get_Sections()->get_Count());
// Add a page break.
builder->Write(String(u"Before page break.") + ControlChar::PageBreak() + u"After page break.");
// A page break is the same value as a section break.
// Insert a new section, and then set its column count to two.
doc->AppendChild(MakeObject<Section>(doc));
builder->MoveToSection(1);
builder->get_CurrentSection()->get_PageSetup()->get_TextColumns()->SetCount(2);
// We can use a control character to mark the point where text moves to the next column.
builder->Write(String(u"Text at end of column 1.") + ControlChar::ColumnBreak() + u"Text at beginning of column 2.");
doc->Save(ArtifactsDir + u"ControlChar.InsertControlChars.docx");
// There are char and string counterparts for most characters.

◆ Tab()

static System::String& Aspose::Words::ControlChar::Tab ( )
static

Tab character: "\x0009" or "\t".

Examples

Shows how to set a custom interval for tab stop positions.

auto doc = MakeObject<Document>();
auto builder = MakeObject<DocumentBuilder>(doc);
// Set tab stops to appear every 72 points (1 inch).
builder->get_Document()->set_DefaultTabStop(72);
// Each tab character snaps the text after it to the next closest tab stop position.
builder->Writeln(String(u"Hello") + ControlChar::Tab() + u"World!");
builder->Writeln(String(u"Hello") + ControlChar::TabChar + u"World!");

Member Data Documentation

◆ CellChar

constexpr char16_t Aspose::Words::ControlChar::CellChar = (char16_t)7
staticconstexpr

End of a table cell or end of a table row character: (char)7 or "\a".

Examples

Shows how to add various control characters to a document.

auto doc = MakeObject<Document>();
auto builder = MakeObject<DocumentBuilder>(doc);
// Add a regular space.
builder->Write(String(u"Before space.") + ControlChar::SpaceChar + u"After space.");
// Add an NBSP, which is a non-breaking space.
// Unlike the regular space, this space cannot have an automatic line break at its position.
builder->Write(String(u"Before space.") + ControlChar::NonBreakingSpace() + u"After space.");
// Add a tab character.
builder->Write(String(u"Before tab.") + ControlChar::Tab() + u"After tab.");
// Add a line break.
builder->Write(String(u"Before line break.") + ControlChar::LineBreak() + u"After line break.");
// Add a new line and starts a new paragraph.
ASSERT_EQ(1, doc->get_FirstSection()->get_Body()->GetChildNodes(NodeType::Paragraph, true)->get_Count());
builder->Write(String(u"Before line feed.") + ControlChar::LineFeed() + u"After line feed.");
ASSERT_EQ(2, doc->get_FirstSection()->get_Body()->GetChildNodes(NodeType::Paragraph, true)->get_Count());
// The line feed character has two versions.
// Carriage returns and line feeds can be represented together by one character.
// Add a paragraph break, which will start a new paragraph.
builder->Write(String(u"Before paragraph break.") + ControlChar::ParagraphBreak() + u"After paragraph break.");
ASSERT_EQ(3, doc->get_FirstSection()->get_Body()->GetChildNodes(NodeType::Paragraph, true)->get_Count());
// Add a section break. This does not make a new section or paragraph.
ASSERT_EQ(1, doc->get_Sections()->get_Count());
builder->Write(String(u"Before section break.") + ControlChar::SectionBreak() + u"After section break.");
ASSERT_EQ(1, doc->get_Sections()->get_Count());
// Add a page break.
builder->Write(String(u"Before page break.") + ControlChar::PageBreak() + u"After page break.");
// A page break is the same value as a section break.
// Insert a new section, and then set its column count to two.
doc->AppendChild(MakeObject<Section>(doc));
builder->MoveToSection(1);
builder->get_CurrentSection()->get_PageSetup()->get_TextColumns()->SetCount(2);
// We can use a control character to mark the point where text moves to the next column.
builder->Write(String(u"Text at end of column 1.") + ControlChar::ColumnBreak() + u"Text at beginning of column 2.");
doc->Save(ArtifactsDir + u"ControlChar.InsertControlChars.docx");
// There are char and string counterparts for most characters.

◆ ColumnBreakChar

constexpr char16_t Aspose::Words::ControlChar::ColumnBreakChar = (char16_t)14
staticconstexpr

End of column character: (char)14.

Examples

Shows how to add various control characters to a document.

auto doc = MakeObject<Document>();
auto builder = MakeObject<DocumentBuilder>(doc);
// Add a regular space.
builder->Write(String(u"Before space.") + ControlChar::SpaceChar + u"After space.");
// Add an NBSP, which is a non-breaking space.
// Unlike the regular space, this space cannot have an automatic line break at its position.
builder->Write(String(u"Before space.") + ControlChar::NonBreakingSpace() + u"After space.");
// Add a tab character.
builder->Write(String(u"Before tab.") + ControlChar::Tab() + u"After tab.");
// Add a line break.
builder->Write(String(u"Before line break.") + ControlChar::LineBreak() + u"After line break.");
// Add a new line and starts a new paragraph.
ASSERT_EQ(1, doc->get_FirstSection()->get_Body()->GetChildNodes(NodeType::Paragraph, true)->get_Count());
builder->Write(String(u"Before line feed.") + ControlChar::LineFeed() + u"After line feed.");
ASSERT_EQ(2, doc->get_FirstSection()->get_Body()->GetChildNodes(NodeType::Paragraph, true)->get_Count());
// The line feed character has two versions.
// Carriage returns and line feeds can be represented together by one character.
// Add a paragraph break, which will start a new paragraph.
builder->Write(String(u"Before paragraph break.") + ControlChar::ParagraphBreak() + u"After paragraph break.");
ASSERT_EQ(3, doc->get_FirstSection()->get_Body()->GetChildNodes(NodeType::Paragraph, true)->get_Count());
// Add a section break. This does not make a new section or paragraph.
ASSERT_EQ(1, doc->get_Sections()->get_Count());
builder->Write(String(u"Before section break.") + ControlChar::SectionBreak() + u"After section break.");
ASSERT_EQ(1, doc->get_Sections()->get_Count());
// Add a page break.
builder->Write(String(u"Before page break.") + ControlChar::PageBreak() + u"After page break.");
// A page break is the same value as a section break.
// Insert a new section, and then set its column count to two.
doc->AppendChild(MakeObject<Section>(doc));
builder->MoveToSection(1);
builder->get_CurrentSection()->get_PageSetup()->get_TextColumns()->SetCount(2);
// We can use a control character to mark the point where text moves to the next column.
builder->Write(String(u"Text at end of column 1.") + ControlChar::ColumnBreak() + u"Text at beginning of column 2.");
doc->Save(ArtifactsDir + u"ControlChar.InsertControlChars.docx");
// There are char and string counterparts for most characters.

◆ DefaultTextInputChar

constexpr char16_t Aspose::Words::ControlChar::DefaultTextInputChar = u'\x2002'
staticconstexpr

This is the "o" character used as a default value in text input form fields.

Examples

Shows how to add various control characters to a document.

auto doc = MakeObject<Document>();
auto builder = MakeObject<DocumentBuilder>(doc);
// Add a regular space.
builder->Write(String(u"Before space.") + ControlChar::SpaceChar + u"After space.");
// Add an NBSP, which is a non-breaking space.
// Unlike the regular space, this space cannot have an automatic line break at its position.
builder->Write(String(u"Before space.") + ControlChar::NonBreakingSpace() + u"After space.");
// Add a tab character.
builder->Write(String(u"Before tab.") + ControlChar::Tab() + u"After tab.");
// Add a line break.
builder->Write(String(u"Before line break.") + ControlChar::LineBreak() + u"After line break.");
// Add a new line and starts a new paragraph.
ASSERT_EQ(1, doc->get_FirstSection()->get_Body()->GetChildNodes(NodeType::Paragraph, true)->get_Count());
builder->Write(String(u"Before line feed.") + ControlChar::LineFeed() + u"After line feed.");
ASSERT_EQ(2, doc->get_FirstSection()->get_Body()->GetChildNodes(NodeType::Paragraph, true)->get_Count());
// The line feed character has two versions.
// Carriage returns and line feeds can be represented together by one character.
// Add a paragraph break, which will start a new paragraph.
builder->Write(String(u"Before paragraph break.") + ControlChar::ParagraphBreak() + u"After paragraph break.");
ASSERT_EQ(3, doc->get_FirstSection()->get_Body()->GetChildNodes(NodeType::Paragraph, true)->get_Count());
// Add a section break. This does not make a new section or paragraph.
ASSERT_EQ(1, doc->get_Sections()->get_Count());
builder->Write(String(u"Before section break.") + ControlChar::SectionBreak() + u"After section break.");
ASSERT_EQ(1, doc->get_Sections()->get_Count());
// Add a page break.
builder->Write(String(u"Before page break.") + ControlChar::PageBreak() + u"After page break.");
// A page break is the same value as a section break.
// Insert a new section, and then set its column count to two.
doc->AppendChild(MakeObject<Section>(doc));
builder->MoveToSection(1);
builder->get_CurrentSection()->get_PageSetup()->get_TextColumns()->SetCount(2);
// We can use a control character to mark the point where text moves to the next column.
builder->Write(String(u"Text at end of column 1.") + ControlChar::ColumnBreak() + u"Text at beginning of column 2.");
doc->Save(ArtifactsDir + u"ControlChar.InsertControlChars.docx");
// There are char and string counterparts for most characters.

◆ FieldEndChar

constexpr char16_t Aspose::Words::ControlChar::FieldEndChar = (char16_t)21
staticconstexpr

End of MS Word field character: (char)21.

Examples

Shows how to add various control characters to a document.

auto doc = MakeObject<Document>();
auto builder = MakeObject<DocumentBuilder>(doc);
// Add a regular space.
builder->Write(String(u"Before space.") + ControlChar::SpaceChar + u"After space.");
// Add an NBSP, which is a non-breaking space.
// Unlike the regular space, this space cannot have an automatic line break at its position.
builder->Write(String(u"Before space.") + ControlChar::NonBreakingSpace() + u"After space.");
// Add a tab character.
builder->Write(String(u"Before tab.") + ControlChar::Tab() + u"After tab.");
// Add a line break.
builder->Write(String(u"Before line break.") + ControlChar::LineBreak() + u"After line break.");
// Add a new line and starts a new paragraph.
ASSERT_EQ(1, doc->get_FirstSection()->get_Body()->GetChildNodes(NodeType::Paragraph, true)->get_Count());
builder->Write(String(u"Before line feed.") + ControlChar::LineFeed() + u"After line feed.");
ASSERT_EQ(2, doc->get_FirstSection()->get_Body()->GetChildNodes(NodeType::Paragraph, true)->get_Count());
// The line feed character has two versions.
// Carriage returns and line feeds can be represented together by one character.
// Add a paragraph break, which will start a new paragraph.
builder->Write(String(u"Before paragraph break.") + ControlChar::ParagraphBreak() + u"After paragraph break.");
ASSERT_EQ(3, doc->get_FirstSection()->get_Body()->GetChildNodes(NodeType::Paragraph, true)->get_Count());
// Add a section break. This does not make a new section or paragraph.
ASSERT_EQ(1, doc->get_Sections()->get_Count());
builder->Write(String(u"Before section break.") + ControlChar::SectionBreak() + u"After section break.");
ASSERT_EQ(1, doc->get_Sections()->get_Count());
// Add a page break.
builder->Write(String(u"Before page break.") + ControlChar::PageBreak() + u"After page break.");
// A page break is the same value as a section break.
// Insert a new section, and then set its column count to two.
doc->AppendChild(MakeObject<Section>(doc));
builder->MoveToSection(1);
builder->get_CurrentSection()->get_PageSetup()->get_TextColumns()->SetCount(2);
// We can use a control character to mark the point where text moves to the next column.
builder->Write(String(u"Text at end of column 1.") + ControlChar::ColumnBreak() + u"Text at beginning of column 2.");
doc->Save(ArtifactsDir + u"ControlChar.InsertControlChars.docx");
// There are char and string counterparts for most characters.

◆ FieldSeparatorChar

constexpr char16_t Aspose::Words::ControlChar::FieldSeparatorChar = (char16_t)20
staticconstexpr

Field separator character separates field code from field value. Optional in some fields. Value: (char)20.

Examples

Shows how to add various control characters to a document.

auto doc = MakeObject<Document>();
auto builder = MakeObject<DocumentBuilder>(doc);
// Add a regular space.
builder->Write(String(u"Before space.") + ControlChar::SpaceChar + u"After space.");
// Add an NBSP, which is a non-breaking space.
// Unlike the regular space, this space cannot have an automatic line break at its position.
builder->Write(String(u"Before space.") + ControlChar::NonBreakingSpace() + u"After space.");
// Add a tab character.
builder->Write(String(u"Before tab.") + ControlChar::Tab() + u"After tab.");
// Add a line break.
builder->Write(String(u"Before line break.") + ControlChar::LineBreak() + u"After line break.");
// Add a new line and starts a new paragraph.
ASSERT_EQ(1, doc->get_FirstSection()->get_Body()->GetChildNodes(NodeType::Paragraph, true)->get_Count());
builder->Write(String(u"Before line feed.") + ControlChar::LineFeed() + u"After line feed.");
ASSERT_EQ(2, doc->get_FirstSection()->get_Body()->GetChildNodes(NodeType::Paragraph, true)->get_Count());
// The line feed character has two versions.
// Carriage returns and line feeds can be represented together by one character.
// Add a paragraph break, which will start a new paragraph.
builder->Write(String(u"Before paragraph break.") + ControlChar::ParagraphBreak() + u"After paragraph break.");
ASSERT_EQ(3, doc->get_FirstSection()->get_Body()->GetChildNodes(NodeType::Paragraph, true)->get_Count());
// Add a section break. This does not make a new section or paragraph.
ASSERT_EQ(1, doc->get_Sections()->get_Count());
builder->Write(String(u"Before section break.") + ControlChar::SectionBreak() + u"After section break.");
ASSERT_EQ(1, doc->get_Sections()->get_Count());
// Add a page break.
builder->Write(String(u"Before page break.") + ControlChar::PageBreak() + u"After page break.");
// A page break is the same value as a section break.
// Insert a new section, and then set its column count to two.
doc->AppendChild(MakeObject<Section>(doc));
builder->MoveToSection(1);
builder->get_CurrentSection()->get_PageSetup()->get_TextColumns()->SetCount(2);
// We can use a control character to mark the point where text moves to the next column.
builder->Write(String(u"Text at end of column 1.") + ControlChar::ColumnBreak() + u"Text at beginning of column 2.");
doc->Save(ArtifactsDir + u"ControlChar.InsertControlChars.docx");
// There are char and string counterparts for most characters.

◆ FieldStartChar

constexpr char16_t Aspose::Words::ControlChar::FieldStartChar = (char16_t)19
staticconstexpr

Start of MS Word field character: (char)19.

Examples

Shows how to add various control characters to a document.

auto doc = MakeObject<Document>();
auto builder = MakeObject<DocumentBuilder>(doc);
// Add a regular space.
builder->Write(String(u"Before space.") + ControlChar::SpaceChar + u"After space.");
// Add an NBSP, which is a non-breaking space.
// Unlike the regular space, this space cannot have an automatic line break at its position.
builder->Write(String(u"Before space.") + ControlChar::NonBreakingSpace() + u"After space.");
// Add a tab character.
builder->Write(String(u"Before tab.") + ControlChar::Tab() + u"After tab.");
// Add a line break.
builder->Write(String(u"Before line break.") + ControlChar::LineBreak() + u"After line break.");
// Add a new line and starts a new paragraph.
ASSERT_EQ(1, doc->get_FirstSection()->get_Body()->GetChildNodes(NodeType::Paragraph, true)->get_Count());
builder->Write(String(u"Before line feed.") + ControlChar::LineFeed() + u"After line feed.");
ASSERT_EQ(2, doc->get_FirstSection()->get_Body()->GetChildNodes(NodeType::Paragraph, true)->get_Count());
// The line feed character has two versions.
// Carriage returns and line feeds can be represented together by one character.
// Add a paragraph break, which will start a new paragraph.
builder->Write(String(u"Before paragraph break.") + ControlChar::ParagraphBreak() + u"After paragraph break.");
ASSERT_EQ(3, doc->get_FirstSection()->get_Body()->GetChildNodes(NodeType::Paragraph, true)->get_Count());
// Add a section break. This does not make a new section or paragraph.
ASSERT_EQ(1, doc->get_Sections()->get_Count());
builder->Write(String(u"Before section break.") + ControlChar::SectionBreak() + u"After section break.");
ASSERT_EQ(1, doc->get_Sections()->get_Count());
// Add a page break.
builder->Write(String(u"Before page break.") + ControlChar::PageBreak() + u"After page break.");
// A page break is the same value as a section break.
// Insert a new section, and then set its column count to two.
doc->AppendChild(MakeObject<Section>(doc));
builder->MoveToSection(1);
builder->get_CurrentSection()->get_PageSetup()->get_TextColumns()->SetCount(2);
// We can use a control character to mark the point where text moves to the next column.
builder->Write(String(u"Text at end of column 1.") + ControlChar::ColumnBreak() + u"Text at beginning of column 2.");
doc->Save(ArtifactsDir + u"ControlChar.InsertControlChars.docx");
// There are char and string counterparts for most characters.

◆ LineBreakChar

constexpr char16_t Aspose::Words::ControlChar::LineBreakChar = (char16_t)11
staticconstexpr

Line break character: (char)11 or "\v".

Examples

Shows how to add various control characters to a document.

auto doc = MakeObject<Document>();
auto builder = MakeObject<DocumentBuilder>(doc);
// Add a regular space.
builder->Write(String(u"Before space.") + ControlChar::SpaceChar + u"After space.");
// Add an NBSP, which is a non-breaking space.
// Unlike the regular space, this space cannot have an automatic line break at its position.
builder->Write(String(u"Before space.") + ControlChar::NonBreakingSpace() + u"After space.");
// Add a tab character.
builder->Write(String(u"Before tab.") + ControlChar::Tab() + u"After tab.");
// Add a line break.
builder->Write(String(u"Before line break.") + ControlChar::LineBreak() + u"After line break.");
// Add a new line and starts a new paragraph.
ASSERT_EQ(1, doc->get_FirstSection()->get_Body()->GetChildNodes(NodeType::Paragraph, true)->get_Count());
builder->Write(String(u"Before line feed.") + ControlChar::LineFeed() + u"After line feed.");
ASSERT_EQ(2, doc->get_FirstSection()->get_Body()->GetChildNodes(NodeType::Paragraph, true)->get_Count());
// The line feed character has two versions.
// Carriage returns and line feeds can be represented together by one character.
// Add a paragraph break, which will start a new paragraph.
builder->Write(String(u"Before paragraph break.") + ControlChar::ParagraphBreak() + u"After paragraph break.");
ASSERT_EQ(3, doc->get_FirstSection()->get_Body()->GetChildNodes(NodeType::Paragraph, true)->get_Count());
// Add a section break. This does not make a new section or paragraph.
ASSERT_EQ(1, doc->get_Sections()->get_Count());
builder->Write(String(u"Before section break.") + ControlChar::SectionBreak() + u"After section break.");
ASSERT_EQ(1, doc->get_Sections()->get_Count());
// Add a page break.
builder->Write(String(u"Before page break.") + ControlChar::PageBreak() + u"After page break.");
// A page break is the same value as a section break.
// Insert a new section, and then set its column count to two.
doc->AppendChild(MakeObject<Section>(doc));
builder->MoveToSection(1);
builder->get_CurrentSection()->get_PageSetup()->get_TextColumns()->SetCount(2);
// We can use a control character to mark the point where text moves to the next column.
builder->Write(String(u"Text at end of column 1.") + ControlChar::ColumnBreak() + u"Text at beginning of column 2.");
doc->Save(ArtifactsDir + u"ControlChar.InsertControlChars.docx");
// There are char and string counterparts for most characters.

◆ LineFeedChar

constexpr char16_t Aspose::Words::ControlChar::LineFeedChar = (char16_t)10
staticconstexpr

Line feed character: (char)10 or "\n".

Examples

Shows how to add various control characters to a document.

auto doc = MakeObject<Document>();
auto builder = MakeObject<DocumentBuilder>(doc);
// Add a regular space.
builder->Write(String(u"Before space.") + ControlChar::SpaceChar + u"After space.");
// Add an NBSP, which is a non-breaking space.
// Unlike the regular space, this space cannot have an automatic line break at its position.
builder->Write(String(u"Before space.") + ControlChar::NonBreakingSpace() + u"After space.");
// Add a tab character.
builder->Write(String(u"Before tab.") + ControlChar::Tab() + u"After tab.");
// Add a line break.
builder->Write(String(u"Before line break.") + ControlChar::LineBreak() + u"After line break.");
// Add a new line and starts a new paragraph.
ASSERT_EQ(1, doc->get_FirstSection()->get_Body()->GetChildNodes(NodeType::Paragraph, true)->get_Count());
builder->Write(String(u"Before line feed.") + ControlChar::LineFeed() + u"After line feed.");
ASSERT_EQ(2, doc->get_FirstSection()->get_Body()->GetChildNodes(NodeType::Paragraph, true)->get_Count());
// The line feed character has two versions.
// Carriage returns and line feeds can be represented together by one character.
// Add a paragraph break, which will start a new paragraph.
builder->Write(String(u"Before paragraph break.") + ControlChar::ParagraphBreak() + u"After paragraph break.");
ASSERT_EQ(3, doc->get_FirstSection()->get_Body()->GetChildNodes(NodeType::Paragraph, true)->get_Count());
// Add a section break. This does not make a new section or paragraph.
ASSERT_EQ(1, doc->get_Sections()->get_Count());
builder->Write(String(u"Before section break.") + ControlChar::SectionBreak() + u"After section break.");
ASSERT_EQ(1, doc->get_Sections()->get_Count());
// Add a page break.
builder->Write(String(u"Before page break.") + ControlChar::PageBreak() + u"After page break.");
// A page break is the same value as a section break.
// Insert a new section, and then set its column count to two.
doc->AppendChild(MakeObject<Section>(doc));
builder->MoveToSection(1);
builder->get_CurrentSection()->get_PageSetup()->get_TextColumns()->SetCount(2);
// We can use a control character to mark the point where text moves to the next column.
builder->Write(String(u"Text at end of column 1.") + ControlChar::ColumnBreak() + u"Text at beginning of column 2.");
doc->Save(ArtifactsDir + u"ControlChar.InsertControlChars.docx");
// There are char and string counterparts for most characters.

◆ NonBreakingHyphenChar

constexpr char16_t Aspose::Words::ControlChar::NonBreakingHyphenChar = (char16_t)30
staticconstexpr

Nonbreaking Hyphen in Microsoft Word is (char)30.

Nonbreaking Hyphen in Microsoft Word does not correspond to the Unicode character U+2011 non-breaking hyphen but instead represents internal information that tells Microsoft Word to display a hyphen and not to break a line.

Useful info: http://www.cs.tut.fi/~jkorpela/dashes.html#linebreaks.

Examples

Shows how to add various control characters to a document.

auto doc = MakeObject<Document>();
auto builder = MakeObject<DocumentBuilder>(doc);
// Add a regular space.
builder->Write(String(u"Before space.") + ControlChar::SpaceChar + u"After space.");
// Add an NBSP, which is a non-breaking space.
// Unlike the regular space, this space cannot have an automatic line break at its position.
builder->Write(String(u"Before space.") + ControlChar::NonBreakingSpace() + u"After space.");
// Add a tab character.
builder->Write(String(u"Before tab.") + ControlChar::Tab() + u"After tab.");
// Add a line break.
builder->Write(String(u"Before line break.") + ControlChar::LineBreak() + u"After line break.");
// Add a new line and starts a new paragraph.
ASSERT_EQ(1, doc->get_FirstSection()->get_Body()->GetChildNodes(NodeType::Paragraph, true)->get_Count());
builder->Write(String(u"Before line feed.") + ControlChar::LineFeed() + u"After line feed.");
ASSERT_EQ(2, doc->get_FirstSection()->get_Body()->GetChildNodes(NodeType::Paragraph, true)->get_Count());
// The line feed character has two versions.
// Carriage returns and line feeds can be represented together by one character.
// Add a paragraph break, which will start a new paragraph.
builder->Write(String(u"Before paragraph break.") + ControlChar::ParagraphBreak() + u"After paragraph break.");
ASSERT_EQ(3, doc->get_FirstSection()->get_Body()->GetChildNodes(NodeType::Paragraph, true)->get_Count());
// Add a section break. This does not make a new section or paragraph.
ASSERT_EQ(1, doc->get_Sections()->get_Count());
builder->Write(String(u"Before section break.") + ControlChar::SectionBreak() + u"After section break.");
ASSERT_EQ(1, doc->get_Sections()->get_Count());
// Add a page break.
builder->Write(String(u"Before page break.") + ControlChar::PageBreak() + u"After page break.");
// A page break is the same value as a section break.
// Insert a new section, and then set its column count to two.
doc->AppendChild(MakeObject<Section>(doc));
builder->MoveToSection(1);
builder->get_CurrentSection()->get_PageSetup()->get_TextColumns()->SetCount(2);
// We can use a control character to mark the point where text moves to the next column.
builder->Write(String(u"Text at end of column 1.") + ControlChar::ColumnBreak() + u"Text at beginning of column 2.");
doc->Save(ArtifactsDir + u"ControlChar.InsertControlChars.docx");
// There are char and string counterparts for most characters.

◆ NonBreakingSpaceChar

constexpr char16_t Aspose::Words::ControlChar::NonBreakingSpaceChar = u'\x00a0'
staticconstexpr

Non-breaking space character: (char)160.

Examples

Shows how to add various control characters to a document.

auto doc = MakeObject<Document>();
auto builder = MakeObject<DocumentBuilder>(doc);
// Add a regular space.
builder->Write(String(u"Before space.") + ControlChar::SpaceChar + u"After space.");
// Add an NBSP, which is a non-breaking space.
// Unlike the regular space, this space cannot have an automatic line break at its position.
builder->Write(String(u"Before space.") + ControlChar::NonBreakingSpace() + u"After space.");
// Add a tab character.
builder->Write(String(u"Before tab.") + ControlChar::Tab() + u"After tab.");
// Add a line break.
builder->Write(String(u"Before line break.") + ControlChar::LineBreak() + u"After line break.");
// Add a new line and starts a new paragraph.
ASSERT_EQ(1, doc->get_FirstSection()->get_Body()->GetChildNodes(NodeType::Paragraph, true)->get_Count());
builder->Write(String(u"Before line feed.") + ControlChar::LineFeed() + u"After line feed.");
ASSERT_EQ(2, doc->get_FirstSection()->get_Body()->GetChildNodes(NodeType::Paragraph, true)->get_Count());
// The line feed character has two versions.
// Carriage returns and line feeds can be represented together by one character.
// Add a paragraph break, which will start a new paragraph.
builder->Write(String(u"Before paragraph break.") + ControlChar::ParagraphBreak() + u"After paragraph break.");
ASSERT_EQ(3, doc->get_FirstSection()->get_Body()->GetChildNodes(NodeType::Paragraph, true)->get_Count());
// Add a section break. This does not make a new section or paragraph.
ASSERT_EQ(1, doc->get_Sections()->get_Count());
builder->Write(String(u"Before section break.") + ControlChar::SectionBreak() + u"After section break.");
ASSERT_EQ(1, doc->get_Sections()->get_Count());
// Add a page break.
builder->Write(String(u"Before page break.") + ControlChar::PageBreak() + u"After page break.");
// A page break is the same value as a section break.
// Insert a new section, and then set its column count to two.
doc->AppendChild(MakeObject<Section>(doc));
builder->MoveToSection(1);
builder->get_CurrentSection()->get_PageSetup()->get_TextColumns()->SetCount(2);
// We can use a control character to mark the point where text moves to the next column.
builder->Write(String(u"Text at end of column 1.") + ControlChar::ColumnBreak() + u"Text at beginning of column 2.");
doc->Save(ArtifactsDir + u"ControlChar.InsertControlChars.docx");
// There are char and string counterparts for most characters.

◆ OptionalHyphenChar

constexpr char16_t Aspose::Words::ControlChar::OptionalHyphenChar = (char16_t)31
staticconstexpr

Optional Hyphen in Microsoft Word is (char)31.

Optional Hyphen in Microsoft Word does not correspond to the Unicode character U+00AD soft hyphen. Instead, it inserts internal information that tells Word about a possible hyphenation point.

Examples

Shows how to add various control characters to a document.

auto doc = MakeObject<Document>();
auto builder = MakeObject<DocumentBuilder>(doc);
// Add a regular space.
builder->Write(String(u"Before space.") + ControlChar::SpaceChar + u"After space.");
// Add an NBSP, which is a non-breaking space.
// Unlike the regular space, this space cannot have an automatic line break at its position.
builder->Write(String(u"Before space.") + ControlChar::NonBreakingSpace() + u"After space.");
// Add a tab character.
builder->Write(String(u"Before tab.") + ControlChar::Tab() + u"After tab.");
// Add a line break.
builder->Write(String(u"Before line break.") + ControlChar::LineBreak() + u"After line break.");
// Add a new line and starts a new paragraph.
ASSERT_EQ(1, doc->get_FirstSection()->get_Body()->GetChildNodes(NodeType::Paragraph, true)->get_Count());
builder->Write(String(u"Before line feed.") + ControlChar::LineFeed() + u"After line feed.");
ASSERT_EQ(2, doc->get_FirstSection()->get_Body()->GetChildNodes(NodeType::Paragraph, true)->get_Count());
// The line feed character has two versions.
// Carriage returns and line feeds can be represented together by one character.
// Add a paragraph break, which will start a new paragraph.
builder->Write(String(u"Before paragraph break.") + ControlChar::ParagraphBreak() + u"After paragraph break.");
ASSERT_EQ(3, doc->get_FirstSection()->get_Body()->GetChildNodes(NodeType::Paragraph, true)->get_Count());
// Add a section break. This does not make a new section or paragraph.
ASSERT_EQ(1, doc->get_Sections()->get_Count());
builder->Write(String(u"Before section break.") + ControlChar::SectionBreak() + u"After section break.");
ASSERT_EQ(1, doc->get_Sections()->get_Count());
// Add a page break.
builder->Write(String(u"Before page break.") + ControlChar::PageBreak() + u"After page break.");
// A page break is the same value as a section break.
// Insert a new section, and then set its column count to two.
doc->AppendChild(MakeObject<Section>(doc));
builder->MoveToSection(1);
builder->get_CurrentSection()->get_PageSetup()->get_TextColumns()->SetCount(2);
// We can use a control character to mark the point where text moves to the next column.
builder->Write(String(u"Text at end of column 1.") + ControlChar::ColumnBreak() + u"Text at beginning of column 2.");
doc->Save(ArtifactsDir + u"ControlChar.InsertControlChars.docx");
// There are char and string counterparts for most characters.

◆ PageBreakChar

constexpr char16_t Aspose::Words::ControlChar::PageBreakChar = (char16_t)12
staticconstexpr

Page break character: (char)12 or "\f".

Examples

Shows how to add various control characters to a document.

auto doc = MakeObject<Document>();
auto builder = MakeObject<DocumentBuilder>(doc);
// Add a regular space.
builder->Write(String(u"Before space.") + ControlChar::SpaceChar + u"After space.");
// Add an NBSP, which is a non-breaking space.
// Unlike the regular space, this space cannot have an automatic line break at its position.
builder->Write(String(u"Before space.") + ControlChar::NonBreakingSpace() + u"After space.");
// Add a tab character.
builder->Write(String(u"Before tab.") + ControlChar::Tab() + u"After tab.");
// Add a line break.
builder->Write(String(u"Before line break.") + ControlChar::LineBreak() + u"After line break.");
// Add a new line and starts a new paragraph.
ASSERT_EQ(1, doc->get_FirstSection()->get_Body()->GetChildNodes(NodeType::Paragraph, true)->get_Count());
builder->Write(String(u"Before line feed.") + ControlChar::LineFeed() + u"After line feed.");
ASSERT_EQ(2, doc->get_FirstSection()->get_Body()->GetChildNodes(NodeType::Paragraph, true)->get_Count());
// The line feed character has two versions.
// Carriage returns and line feeds can be represented together by one character.
// Add a paragraph break, which will start a new paragraph.
builder->Write(String(u"Before paragraph break.") + ControlChar::ParagraphBreak() + u"After paragraph break.");
ASSERT_EQ(3, doc->get_FirstSection()->get_Body()->GetChildNodes(NodeType::Paragraph, true)->get_Count());
// Add a section break. This does not make a new section or paragraph.
ASSERT_EQ(1, doc->get_Sections()->get_Count());
builder->Write(String(u"Before section break.") + ControlChar::SectionBreak() + u"After section break.");
ASSERT_EQ(1, doc->get_Sections()->get_Count());
// Add a page break.
builder->Write(String(u"Before page break.") + ControlChar::PageBreak() + u"After page break.");
// A page break is the same value as a section break.
// Insert a new section, and then set its column count to two.
doc->AppendChild(MakeObject<Section>(doc));
builder->MoveToSection(1);
builder->get_CurrentSection()->get_PageSetup()->get_TextColumns()->SetCount(2);
// We can use a control character to mark the point where text moves to the next column.
builder->Write(String(u"Text at end of column 1.") + ControlChar::ColumnBreak() + u"Text at beginning of column 2.");
doc->Save(ArtifactsDir + u"ControlChar.InsertControlChars.docx");
// There are char and string counterparts for most characters.

◆ ParagraphBreakChar

constexpr char16_t Aspose::Words::ControlChar::ParagraphBreakChar = (char16_t)13
staticconstexpr

End of paragraph character: (char)13 or "\r".

Examples

Shows how to add various control characters to a document.

auto doc = MakeObject<Document>();
auto builder = MakeObject<DocumentBuilder>(doc);
// Add a regular space.
builder->Write(String(u"Before space.") + ControlChar::SpaceChar + u"After space.");
// Add an NBSP, which is a non-breaking space.
// Unlike the regular space, this space cannot have an automatic line break at its position.
builder->Write(String(u"Before space.") + ControlChar::NonBreakingSpace() + u"After space.");
// Add a tab character.
builder->Write(String(u"Before tab.") + ControlChar::Tab() + u"After tab.");
// Add a line break.
builder->Write(String(u"Before line break.") + ControlChar::LineBreak() + u"After line break.");
// Add a new line and starts a new paragraph.
ASSERT_EQ(1, doc->get_FirstSection()->get_Body()->GetChildNodes(NodeType::Paragraph, true)->get_Count());
builder->Write(String(u"Before line feed.") + ControlChar::LineFeed() + u"After line feed.");
ASSERT_EQ(2, doc->get_FirstSection()->get_Body()->GetChildNodes(NodeType::Paragraph, true)->get_Count());
// The line feed character has two versions.
// Carriage returns and line feeds can be represented together by one character.
// Add a paragraph break, which will start a new paragraph.
builder->Write(String(u"Before paragraph break.") + ControlChar::ParagraphBreak() + u"After paragraph break.");
ASSERT_EQ(3, doc->get_FirstSection()->get_Body()->GetChildNodes(NodeType::Paragraph, true)->get_Count());
// Add a section break. This does not make a new section or paragraph.
ASSERT_EQ(1, doc->get_Sections()->get_Count());
builder->Write(String(u"Before section break.") + ControlChar::SectionBreak() + u"After section break.");
ASSERT_EQ(1, doc->get_Sections()->get_Count());
// Add a page break.
builder->Write(String(u"Before page break.") + ControlChar::PageBreak() + u"After page break.");
// A page break is the same value as a section break.
// Insert a new section, and then set its column count to two.
doc->AppendChild(MakeObject<Section>(doc));
builder->MoveToSection(1);
builder->get_CurrentSection()->get_PageSetup()->get_TextColumns()->SetCount(2);
// We can use a control character to mark the point where text moves to the next column.
builder->Write(String(u"Text at end of column 1.") + ControlChar::ColumnBreak() + u"Text at beginning of column 2.");
doc->Save(ArtifactsDir + u"ControlChar.InsertControlChars.docx");
// There are char and string counterparts for most characters.

◆ SectionBreakChar

constexpr char16_t Aspose::Words::ControlChar::SectionBreakChar = (char16_t)12
staticconstexpr

End of section character: (char)12 or "\f".

Examples

Shows how to add various control characters to a document.

auto doc = MakeObject<Document>();
auto builder = MakeObject<DocumentBuilder>(doc);
// Add a regular space.
builder->Write(String(u"Before space.") + ControlChar::SpaceChar + u"After space.");
// Add an NBSP, which is a non-breaking space.
// Unlike the regular space, this space cannot have an automatic line break at its position.
builder->Write(String(u"Before space.") + ControlChar::NonBreakingSpace() + u"After space.");
// Add a tab character.
builder->Write(String(u"Before tab.") + ControlChar::Tab() + u"After tab.");
// Add a line break.
builder->Write(String(u"Before line break.") + ControlChar::LineBreak() + u"After line break.");
// Add a new line and starts a new paragraph.
ASSERT_EQ(1, doc->get_FirstSection()->get_Body()->GetChildNodes(NodeType::Paragraph, true)->get_Count());
builder->Write(String(u"Before line feed.") + ControlChar::LineFeed() + u"After line feed.");
ASSERT_EQ(2, doc->get_FirstSection()->get_Body()->GetChildNodes(NodeType::Paragraph, true)->get_Count());
// The line feed character has two versions.
// Carriage returns and line feeds can be represented together by one character.
// Add a paragraph break, which will start a new paragraph.
builder->Write(String(u"Before paragraph break.") + ControlChar::ParagraphBreak() + u"After paragraph break.");
ASSERT_EQ(3, doc->get_FirstSection()->get_Body()->GetChildNodes(NodeType::Paragraph, true)->get_Count());
// Add a section break. This does not make a new section or paragraph.
ASSERT_EQ(1, doc->get_Sections()->get_Count());
builder->Write(String(u"Before section break.") + ControlChar::SectionBreak() + u"After section break.");
ASSERT_EQ(1, doc->get_Sections()->get_Count());
// Add a page break.
builder->Write(String(u"Before page break.") + ControlChar::PageBreak() + u"After page break.");
// A page break is the same value as a section break.
// Insert a new section, and then set its column count to two.
doc->AppendChild(MakeObject<Section>(doc));
builder->MoveToSection(1);
builder->get_CurrentSection()->get_PageSetup()->get_TextColumns()->SetCount(2);
// We can use a control character to mark the point where text moves to the next column.
builder->Write(String(u"Text at end of column 1.") + ControlChar::ColumnBreak() + u"Text at beginning of column 2.");
doc->Save(ArtifactsDir + u"ControlChar.InsertControlChars.docx");
// There are char and string counterparts for most characters.

◆ SpaceChar

constexpr char16_t Aspose::Words::ControlChar::SpaceChar = (char16_t)32
staticconstexpr

Space character: (char)32.

Examples

Shows how to add various control characters to a document.

auto doc = MakeObject<Document>();
auto builder = MakeObject<DocumentBuilder>(doc);
// Add a regular space.
builder->Write(String(u"Before space.") + ControlChar::SpaceChar + u"After space.");
// Add an NBSP, which is a non-breaking space.
// Unlike the regular space, this space cannot have an automatic line break at its position.
builder->Write(String(u"Before space.") + ControlChar::NonBreakingSpace() + u"After space.");
// Add a tab character.
builder->Write(String(u"Before tab.") + ControlChar::Tab() + u"After tab.");
// Add a line break.
builder->Write(String(u"Before line break.") + ControlChar::LineBreak() + u"After line break.");
// Add a new line and starts a new paragraph.
ASSERT_EQ(1, doc->get_FirstSection()->get_Body()->GetChildNodes(NodeType::Paragraph, true)->get_Count());
builder->Write(String(u"Before line feed.") + ControlChar::LineFeed() + u"After line feed.");
ASSERT_EQ(2, doc->get_FirstSection()->get_Body()->GetChildNodes(NodeType::Paragraph, true)->get_Count());
// The line feed character has two versions.
// Carriage returns and line feeds can be represented together by one character.
// Add a paragraph break, which will start a new paragraph.
builder->Write(String(u"Before paragraph break.") + ControlChar::ParagraphBreak() + u"After paragraph break.");
ASSERT_EQ(3, doc->get_FirstSection()->get_Body()->GetChildNodes(NodeType::Paragraph, true)->get_Count());
// Add a section break. This does not make a new section or paragraph.
ASSERT_EQ(1, doc->get_Sections()->get_Count());
builder->Write(String(u"Before section break.") + ControlChar::SectionBreak() + u"After section break.");
ASSERT_EQ(1, doc->get_Sections()->get_Count());
// Add a page break.
builder->Write(String(u"Before page break.") + ControlChar::PageBreak() + u"After page break.");
// A page break is the same value as a section break.
// Insert a new section, and then set its column count to two.
doc->AppendChild(MakeObject<Section>(doc));
builder->MoveToSection(1);
builder->get_CurrentSection()->get_PageSetup()->get_TextColumns()->SetCount(2);
// We can use a control character to mark the point where text moves to the next column.
builder->Write(String(u"Text at end of column 1.") + ControlChar::ColumnBreak() + u"Text at beginning of column 2.");
doc->Save(ArtifactsDir + u"ControlChar.InsertControlChars.docx");
// There are char and string counterparts for most characters.

◆ TabChar

constexpr char16_t Aspose::Words::ControlChar::TabChar = (char16_t)9
staticconstexpr

Tab character: (char)9 or "\t".

Examples

Shows how to set a custom interval for tab stop positions.

auto doc = MakeObject<Document>();
auto builder = MakeObject<DocumentBuilder>(doc);
// Set tab stops to appear every 72 points (1 inch).
builder->get_Document()->set_DefaultTabStop(72);
// Each tab character snaps the text after it to the next closest tab stop position.
builder->Writeln(String(u"Hello") + ControlChar::Tab() + u"World!");
builder->Writeln(String(u"Hello") + ControlChar::TabChar + u"World!");