Solved

File formats

Posted on 2003-12-11
15
335 Views
Last Modified: 2013-11-22
Hello,

Can anyone please point me to a tutorial,some code or at least tell me some theory on creating my own text format (like .doc , .rtf , so on) and making it unreadable by Notepad (<-- bloody thing reads everything :D :D)
Thanks alot!
0
Comment
Question by:Prototype_T-104
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 7
  • 7
15 Comments
 
LVL 8

Expert Comment

by:gmayo
ID: 9920546
That's right - it WILL load anything - it don't matter what text format you use! However, if the first two letters of the file are MZ, then WordPad won't load it (it thinks it is an exe). Notepad will load it though.

If you don't want anybody to view your data, you need to encrypt it. This can be as simple as inverting every character or as complex as 128-bit encryption they use for Internet banking and suchlike. Inverting characters is just a case of c:=Chr(255 - Ord(c));

Geoff M.
0
 
LVL 5

Expert Comment

by:-Thespian-
ID: 9920950
Try this:

-----------------------------------------------
type
  TMyCharType=record
    MChar: byte;
    MBold: boolean;
    MItalic: boolean;
.................
    MSize: byte;
  end;
  TMyFileType=file of TMyCharType;
------------------------------------------------

Read and Write file record to record (char to char) and you will have a richedit text

____________
But it is not optimized/
0
 

Author Comment

by:Prototype_T-104
ID: 9923213
Ummm could you please explain it a little bit? Thanks alot!
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 8

Expert Comment

by:gmayo
ID: 9923250
Which one of us are you responding to?

Geoff M.
0
 

Author Comment

by:Prototype_T-104
ID: 9924109
Your's replay was clear the Thespians was a little confusing :)
0
 
LVL 8

Expert Comment

by:gmayo
ID: 9926786
Well, to be honest, Thespian's answer is not exactly efficient. For every character in the file, there'll be 4 characters saved, ie your file will be 4x bigger than it needs to be. And you'll STILL be able to read it with NotePad.

Geoff M.
0
 

Author Comment

by:Prototype_T-104
ID: 9927060
Yes, are there any tutorials or examples on this matter??
0
 
LVL 8

Expert Comment

by:gmayo
ID: 9927201
var f : file of TMyRec;
rec1, rec2 : TMyRec;

Write:
AssignFile(f, 'filename.txt');
Rewrite(f);
Write(f, rec1);
Write(f, rec2);
CloseFile(f);

Read:
AssignFile(f, 'filename.txt');
Reset(f);
Read(f, rec1);
Read(f, rec2);
CloseFile(f);

Geoff M.
0
 

Author Comment

by:Prototype_T-104
ID: 9931287
So to reatin the full formatting i would have to write for each charachter their properties?!
0
 
LVL 8

Expert Comment

by:gmayo
ID: 9931331
No, that's inefficient. I'm starting to wonder exactly what you want though. Do you want something which Notepad users can't read (ie encryption) or do you want a custom text format (ie with formatting)?

Geoff M.
0
 

Author Comment

by:Prototype_T-104
ID: 9933690
Well for start a custom text format, but later if it would be a nice feature to encrypt it. So for now its just a custom text format.
0
 
LVL 8

Accepted Solution

by:
gmayo earned 95 total points
ID: 9933790
Ok, well one way would be to use some of the control characters to control formatting. For example, use #30 to turn on bold and #31 to turn it off. All the characters in between would be bold. Another way is to use special combinations of printable characters like HTML or RTF - <B> and </B> for HTML, RTS might be something like -{Bold}- but I don't know exactly.

Geoff M.
0
 

Author Comment

by:Prototype_T-104
ID: 9933880
Hey now i am starting to get it... so i would write a parser that load each line, gets the formatting tag and formats the text accordingly!
Thanks alot so far Geoff you really are a big help!
0
 
LVL 8

Expert Comment

by:gmayo
ID: 9933896
That's right. Just make sure that the formatting characters can't be typed by a human, causing unwanted effects. For example, you don't want somebody to type "to boldly go where..." and have everything from the LY onwards in bold!

Geoff M.
0
 

Author Comment

by:Prototype_T-104
ID: 9933908
Ok thanks!
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

733 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question