Solved

File formats

Posted on 2003-12-11
15
336 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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

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…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
Come and listen to Percona CEO Peter Zaitsev discuss what’s new in Percona open source software, including Percona Server for MySQL (https://www.percona.com/software/mysql-database/percona-server) and MongoDB (https://www.percona.com/software/mongo-…
If you're a developer or IT admin, you’re probably tasked with managing multiple websites, servers, applications, and levels of security on a daily basis. While this can be extremely time consuming, it can also be frustrating when systems aren't wor…

690 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