Board index » cppbuilder » TRichEdit saved file shows garbage in Notepad

TRichEdit saved file shows garbage in Notepad


2005-05-26 01:13:55 AM
cppbuilder94
Hello,
I saved a file using TRichEdit. When I open the same file in
notpad I see lots of formatting stuff before I see the actual
text.
For example, I saved "Whats going on?" in a file using TRichEdit
when I open it i a notpad, it looks like this...
{\rtf1\ansi\ansicpg932\deff0\deflang1033\deflangfe1041{\fonttbl
{\f0\fnil\fcharset0 MS Sans Serif;}{\f1\fnil MS Sans Serif;}}
{\colortbl ;\red255\green255\blue255;}
\viewkind4\uc1\pard\cf1\f0\fs24 whats going on?\lang1041\f1
\par }
However, when i open the same file in TRichEdit again, it looks
fine.
I tried with PlainText property both True and False, but same
results.
Can someone help me and tell me how I can fix this problem??
thanks,
Veebo
 
 

Re:TRichEdit saved file shows garbage in Notepad

Quote
I saved a file using TRichEdit. When I open the same file in
notpad I see lots of formatting stuff before I see the actual
text.
Yes, that's the way RTF format is supposed to be. RTF is much
more than a simple TXT (PlainText) because it holds many
formating attributes that TXT does not have.
Quote
However, when i open the same file in TRichEdit again, it looks
fine.
The more reasons to 'beleave' that the text format was OK ;)
Quote
I tried with PlainText property both True and False, but same
results.
Check once again. You must have been overlooked something.
When you set PlainText to true, than the entered text is saved
RichEdit::SaveToFile in pure TXT format.
Quote
Can someone help me and tell me how I can fix this problem??
See below, it's not the problem.
--
Best regards,
Vladimir Stefanovic
 

Re:TRichEdit saved file shows garbage in Notepad

"Veebo" < XXXX@XXXXX.COM >wrote in message
Quote
I saved a file using TRichEdit. When I open the same file in
notpad I see lots of formatting stuff before I see the actual
text.
As well you should be. TRichEdit uses RTF (rich text format), not plain
text. If you don't want the formatting, then you need to set the RichEdit's
PlainText property to true before saving the file.
Quote
However, when i open the same file in TRichEdit again, it looks
fine.
Of course, because the RichEdit is parsing the RTF coding.
Quote
I tried with PlainText property both True and False, but
same results.
That is very doubtful, because what you are asking for that is exactly what
the PlainText property is actually for to begin with. The following works
fine for me:
RichEdit1->PlainText = false;
RichEdit1->Lines->SaveToFile(".\\test.rtf"); // <-- RTF coding is
present
RichEdit1->PlainText = true;
RichEdit1->Lines->SaveToFile(".\\test.txt"); // <-- RTF coding is NOT
present
Gambit
 

{smallsort}

Re:TRichEdit saved file shows garbage in Notepad

thanks guys for your response (Gambit and Vlade)
As I mentioned, for some reason eventhough I used PlainText =
true, it wasn't working for me. Turns out that sometimes
BCB has issues and when you make a change and re-run the
project it executes the old .exe (I have encountered this
problem in past)
so, first I felt that PlainText = true is not the solution, but
after I saw you guys' response and realized that PlainText is
the solution, I deleted the .obj and .exe files and re-ran the
project and it work.
thanks for your help,
cheers,
Veebo
"Remy Lebeau \(TeamB\)" < XXXX@XXXXX.COM >wrote:
Quote
RichEdit1->PlainText = true;
RichEdit1->Lines->SaveToFile(".\\test.txt"); // <-- RTF coding is NOT
present


Gambit