Differentiating between binary and ASCII input streams
I am currently working on a project where I will be having both binary and text information streams. If the stream is binary then I do nothing and send it on. If the stream is text then I need to do some parsing. Does anyone have a great suggestion for quickly and reliably determing whether a buffer contains binary information or not?
I'm looking at the source for the UNIX "strings" command and may steal code out of that but I thought I would check to see if there are other methods. Ideally I would want to check the first few bytes of the buffer so I don't get bugs if the first byte of the binary coincidentally maps to an ASCII character.