Solved

File formats

Posted on 2003-12-11
15
329 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
  • 7
  • 7
15 Comments
 
LVL 8

Expert Comment

by:gmayo
Comment Utility
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-
Comment Utility
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
Comment Utility
Ummm could you please explain it a little bit? Thanks alot!
0
 
LVL 8

Expert Comment

by:gmayo
Comment Utility
Which one of us are you responding to?

Geoff M.
0
 

Author Comment

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

Expert Comment

by:gmayo
Comment Utility
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
Comment Utility
Yes, are there any tutorials or examples on this matter??
0
Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

 
LVL 8

Expert Comment

by:gmayo
Comment Utility
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
Comment Utility
So to reatin the full formatting i would have to write for each charachter their properties?!
0
 
LVL 8

Expert Comment

by:gmayo
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
Ok thanks!
0

Featured Post

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
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…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

762 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now