2006. október 9., hétfő

How to detect a CR / LF in a TRichEdit


I need to determine where there are CR/LF's in a TRichEdit. Here's the problem. I need to use the TRichEdit to take pretty much just plain text. I am using the TRichEdit instead of the TMemo because it handles end-of-line spaces much better. When I save the text, I need to save it in a proprietary text format. So when I encounter a CRLF, I need to place a "/p" combination at the end of the text line.


procedure SaveTextWithParagraphMarkers(const filename, Text, marker: string);
  fs: TFilestream;
  S: string;
  S := Stringreplace(text, #13#10, marker, [srReplaceAll]);
  fs := TFilestream.Create(filename, fmCreate);
    fs.WriteBuffer(S[1], Length(S));

SaveTextWithParagraphMakers(filename, richedit1.text, '/p'#13#10);

Nincsenek megjegyzések:

Megjegyzés küldése