detect if a message string is QP Encoded
On FreeBsd system, i am trying to determine开发者_Go百科 if an email message in the form of a c style string is qp encoded?
Is there a unix tool like iconv which can read in chunk of data and output the detected encoding? like charset detection?
any ideas?
Really, you should get this information from the source of the data. Quoted-printable data should always be flagged as such. There's no 100% certain way to determine that data is QP since the key property of QP is that it's valid plain ASCII text. If the data contains a number of =XX sequences, and doesn't contain anything invalid in QP (like high bytes), then it's probably intended as QP, but that's about the best you can do.
You look at the Content-Transfer-Encoding header field. See http://en.wikipedia.org/wiki/MIME for a starting point, including links to specifications.
精彩评论