與控制字元工作
Contents
[
Hide
]
Microsoft Word 文檔可能包含各種特殊含義的字符。 通常它們是用來做格式化的,在正常模式下不會被繪製。 你可以透過標準工具列上的顯示/隱藏格式標記按鈕來使它們顯露。
有時您可能需要新增或移除文字中的字元 。 例如,當從文件中程式化獲取文字時,Aspose.Words會保存大多數控制字元,因此如果你需要處理這些文字,你應該將字元移除或替換。
ControlChar這個類別是常在文件中出現的控制字常數的存放庫。 它提供 char 和 string 兩種版本的同一個常數。 例如,字串 LineBreak 和字符 LineBreakChar 具有相同的值。
以下範例顯示如何使用控制字元:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-words/Aspose.Words-for-.NET | |
string text = "test\r"; | |
// Replace "\r" control character with "\r\n" | |
text = text.Replace(ControlChar.Cr, ControlChar.CrLf); |