Ok. My question is confusing, but what im asking is how could i create my own file with my own encoding representing data. sorta like my own database file with my own encoding ,headers, and info.

  • Start by picking a programming language. And tagging your question with the language. – John Wu Feb 22 '17 at 0:10
  • There are some existing resources for designing file formats. What I would consider to be the most important piece of advice is to fully design your file format first, before you start to implement it. – Kevin Feb 22 '17 at 0:30
  • 2
    If you start your implementation too early, you're very likely to tie your specification very strongly to your implementation, or to change your specification to suit the whims of your implementation (what's easier to add to your implementation vs what makes sense in the file format). Even worse, you might treat your implementation as the specification. – Kevin Feb 22 '17 at 0:33

That's easy: you write down what the rules of your encoding are. Done. You have created an encoding. All you need is a pen and some paper. Actually, the paper is optional: Ken Thompson created UTF-8 on a placemat in a diner in a single evening. Actually, even the pen is optional, too: I designed a text file format for campfire song lead sheets entirely in my head. The file format specification still exists only in my head, it was never written down anywhere nor was it ever implemented. It's pretty useless, since nobody except me knows about it, but still, it exists, and I created it in about 1.5 hours.

If you want anyone to take your encoding seriously, you'll have to implement it. Even better would be if you use this implementation in a large and complex system and show that it works, performs well, and scales.

Having a written specification in a formal language and a conformance test suite also helps foster alternative implementations and competition.

An important bit of advice is to keep it simple: the specification for Open OfficeXML (the ECMA/ISO standard based on Microsoft Office's XML file format and competitor to the OpenDocument format aka OpenOffice XML) is over 6500 pages, and to this day, no office application, not even Microsoft Office implements it fully. In fact, it cannot be fully implemented because it is logically inconsistent and contradicts itself. Don't fall into the same trap!

  • btw I was trying to do this in cpp – Fumerian Gaming Feb 22 '17 at 22:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.