Microsoft Word documents may contain various characters that have a special meaning. They are normally used for formatting purposes and are not drawn in the normal mode. You can get them visible if you click the Show/Hide Formatting Marks button located on the Standard toolbar.
Sometimes you may need to add or remove these characters to/from the text. For instance, when obtaining the text programmatically from the document, Aspose.Words preserves most of the control characters so if you need to work with this text you should probably remove or replace the characters.
The ControlChar class is a storage for the constants that represent control characters often encountered in documents. It provides both char and string versions of the same constants. For example, string ControlChar.LineBreak and char ControlChar.LineBreakChar have the same value.
Use this class whenever you want to deal with the control characters.
Example UtilityClassesUseControlCharacters
Shows how to use control characters.
[C#]
// Replace "\r" control character with "\r\n"
text = text.Replace(ControlChar.Cr, ControlChar.CrLf);
[Visual Basic]
' Replace "\r" control character with "\r\n"
text = text.Replace(ControlChar.Cr, ControlChar.CrLf)
[Java]
// Replace "\r" control character with "\r\n"
text = text.replace(ControlChar.CR, ControlChar.CR_LF);