I am looking for a robust way in Java to test if a text fragment is quoted-printable encoded. The most straightforward way would be to test whether a string contains c开发者_开发技巧har sequences which match the following regular expression: (=[A–F0-9][A–F0-9])|(=[\r][\n])
(encoded characters + =
and soft break for a newline).
I would negate the test; text which contains = followed by anything other than newline or two hex digits is not QP; but this is still a weak heuristic - somebody could put =3D
in unencoded text just for the heck of it (and I just did). Bottom line: if you don't know the encoding, you don't know the encoding.
精彩评论