Author: Jonas Bilinkevicius
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.
Answer:
1 2 procedure SaveTextWithParagraphMarkers(const filename, Text, marker: string);
3 var4 fs: TFilestream;
5 S: string;
6 begin7 S := Stringreplace(text, #13#10, marker, [srReplaceAll]);
8 fs := TFilestream.Create(filename, fmCreate);
9 try10 fs.WriteBuffer(S[1], Length(S));
11 finally12 fs.Free
13 end;
14 end;
15 16 SaveTextWithParagraphMakers(filename, richedit1.text, '/p'#13#10);