Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Convert RTF To Ascii

1,206 views
Skip to first unread message

Michael Dillon

unread,
Aug 24, 2001, 6:52:47 AM8/24/01
to
Does anybody know a way of converting RTF to ASCII,
I have tried using the rich edit / memo to convert the RTF to plain text,
while this works on Windows 2000, its not working for Win 95 - 98, NT 4 with
service pack 6 ( although it is working on some Windows NT)

If anybody can help, that would be great.

Just to say that the Win 95 and Win 98 have the most recent version of
microsoft common controls installed.


Mike Orriss (TeamB)

unread,
Aug 24, 2001, 9:26:53 AM8/24/01
to
In article <3b86317b_2@dnews>, Michael Dillon wrote:
> while this works on Windows 2000, its not working for Win 95 - 98, NT 4 with
> service pack 6 ( although it is working on some Windows NT)
>

how is it not working?

Mike Orriss (TeamB and DevExpress)


Michael Dillon

unread,
Aug 24, 2001, 10:11:53 AM8/24/01
to
It does not strip out the rtf.


"Mike Orriss (TeamB)" <m...@3kcc.co.uk> wrote in message
news:VA.000024c0.06139005@pcmike1...

Michael Dillon

unread,
Aug 24, 2001, 12:13:38 PM8/24/01
to
It does not remove the RTF formating text from the string, to leave me just
the ascii.

Thanks.


"Mike Orriss (TeamB)" <m...@3kcc.co.uk> wrote in message
news:VA.000024c0.06139005@pcmike1...

Mike Orriss (TeamB)

unread,
Aug 24, 2001, 1:00:55 PM8/24/01
to
In article <3b866034$1_2@dnews>, Michael Dillon wrote:
> It does not strip out the rtf.
>

Well, it has always worked for me on Win98/NT/W2K.

Peter Below (TeamB)

unread,
Aug 25, 2001, 9:07:46 AM8/25/01
to
In article <3b86317b_2@dnews>, Michael Dillon wrote:
> Does anybody know a way of converting RTF to ASCII,
> I have tried using the rich edit / memo to convert the RTF to plain text,
> while this works on Windows 2000, its not working for Win 95 - 98, NT 4 with
> service pack 6 ( although it is working on some Windows NT)

If you set a richedits Plaintext property to true and then stream the LInes
property to memory or filestream you get the plain text. If you assign the
richedits Text property to a string you get the plain text. The only situation
under which this would yield the RTF text is when you have loaded a RTF file
via Lines.LoadFromFile or stream and PlainText was already true. In that case
the RTF would be treated as plain text.

> If anybody can help, that would be great.

We cannot help you if you don't show us the code you are using.


Peter Below (TeamB) 10011...@compuserve.com)
No e-mail responses, please, unless explicitly requested!
Note: I'm unable to visit the newsgroups every day at the moment,
so be patient if you don't get a reply immediately.

Michael Dillon

unread,
Aug 27, 2001, 6:50:28 AM8/27/01
to
Hi

Here is the code I've been using, the RTF is passed as the parameter
'aString' and the ASCII text is returned.

RichEdit is a TRichEdit.

Thanks.

function
TTKNotesObjectRichEditForms.ConvertRTFToAsciiText(aString:string):string;
var
varString:string;
begin
RichEdit1.Text:='';
Richedit1.PlainText := FALSE;
RichEdit1.Text := aString;
Richedit1.PlainText := TRUE;
varString:=RichEdit1.Text;
Result := String(varString);
end;


Peter Below (TeamB)

unread,
Aug 27, 2001, 1:31:31 PM8/27/01
to
In article <3b8a2570$1_1@dnews>, Michael Dillon wrote:
> Here is the code I've been using, the RTF is passed as the parameter
> 'aString' and the ASCII text is returned.
>
> function
> TTKNotesObjectRichEditForms.ConvertRTFToAsciiText(aString:string):string;
> var
> varString:string;
> begin
> RichEdit1.Text:='';
> Richedit1.PlainText := FALSE;
> RichEdit1.Text := aString;

That does not do what you expect it to do. The Plaintext property is
*only* relevant for the richedit.lines.Loadfrom* and SaveTo* methods,
nowhere else. So what you do is storing the rich text as plain text into
the control, including all formatting characters. The way to go is this:


function
TTKNotesObjectRichEditForms.ConvertRTFToAsciiText(aString:string):string;
var

ss:tstringstream;
begin
ss:= TStringstream.Create( aString );
try
Richedit1.PlainText := FALSE;
Richedit1.Lines.LoadFromStream( ss );
finally
ss.free
end;
Result := RichEdit1.Text;
end;

Michael Dillon

unread,
Aug 28, 2001, 5:19:47 AM8/28/01
to
Thanks very much Peter, that worked a treat, thanks, thanks, thanks,
thanks, thanks.

Michael


0 new messages