Treatment method of javamail Chinese attachment

zhaozj2021-02-16  41

JavaMail can support Chinese, but found in the test process with javamail with Chinese file name

Attachment, the file name is garbled, the test and viewing source file is found, a write message in javamail package

The method does not consider international factors, and there is no consideration for double-bytes or multi-byte characters. Be

com.sun.mail.util.LineOutputStream call

com.sun.mail.util.asciiutility.getbytes (String s);

This method directly converts the string into characters and converts into bytes. In fact, getBytes () in the String class

The method can directly convert into one-by-one code code according to the default encoding of the system.

Workaround: Adding the com.sun.mail.util.LineoutputStream; String S);

The part of the method is changed to S.GetBytes () solves this problem.

Replace the COM / Sun / Mail / Util / LineoutPutStream.class file in javamail with recompiled LINEOUTSTREAM.CLASS files

转载请注明原文地址:https://www.9cbs.com/read-26241.html

New Post(0)