private static void AppendTextToBlock(string text, TextBlockBuilder builder) { if (string.IsNullOrEmpty(text)) { return; } // Replace \r\n combinations with \n, and then replace \r with \n text = text.Replace("\r\n", "\n"); text = text.Replace("\r", "\n"); char lastchar = '\0'; foreach (char ch in text) { if (ch == '\n') { builder.Append(TagId.EOL); } else { builder.AppendChar(ch); lastchar = ch; } } }