开发者

How to test if a text fragment is Quoted-printable encoded

开发者 https://www.devze.com 2023-04-02 20:41 出处:网络
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 whic

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消