4 ms·
The lesson here is when choosing your new file format's magic bytes, don't use your initials or something clever. Have the decency to use a few actual random by
by AndyKelley 10y ago
The lesson here is when choosing your new file format's magic bytes, don't use your initials or something clever. Have the decency to use a few actual random bytes as your format's identifier.
For plain text files, it's a little bit different, but there's no excuse for this problem happening in a binary file format.
Switching topics, I'm imagining a solution to this problem where you don't actually know which format it is, you have a streaming processor for each thing it could be, and feed it to each processor one character at a time. Whenever a processor returns an error, drop it from the list. If the last processor in the list returns and error, report that error to the user along with which format that processor was for. If multiple peocessors complete successfully, you'll have to either rank them, or ask the user what format it is.
- mark-r 10y agoSYLK isn't binary, it's all ASCII. Interesting idea on passing the file to multiple parsers simultaneously, although I don't see a benefit over trying them serially.