【问题标题】:Euro-Sign is not properly Quoted-Printable encodedEuro-Sign 未正确引用 - 可打印编码
【发布时间】:2020-03-16 10:06:26
【问题描述】:

我们正在尝试编码 NonBreaking-Space (0xC2 0xA0) 和 Euro-Sign (0xE2 0x82 0xAC) 使用 Spring MimeMessageHelper setText https://docs.spring.io/spring-framework/docs/current/javadoc-api/org/springframework/mail/javamail/MimeMessageHelper.html#setText-java.lang.String-java.lang.String-

对于 html-body,我们得到输出 =C2=A0?,这是正确的空格,后跟替换字符“?”。

From: nix@foo.de
Reply-To: valid@foo.de
To: valid@foo.de
Message-ID: <935520971.3.1574258294133@hp-machine>
Subject: testing email
MIME-Version: 1.0
Content-Type: multipart/mixed; 
    boundary="----=_Part_0_1089341986.1574258294045"

------=_Part_0_1089341986.1574258294045
Content-Type: multipart/related; 
    boundary="----=_Part_1_801142660.1574258294066"

------=_Part_1_801142660.1574258294066
Content-Type: multipart/alternative; 
    boundary="----=_Part_2_685219002.1574258294091"

------=_Part_2_685219002.1574258294091
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: base64

MjgsNDDCoOKCrA==
------=_Part_2_685219002.1574258294091
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

28,40=C2=A0?
------=_Part_2_685219002.1574258294091--

------=_Part_1_801142660.1574258294066--

------=_Part_0_1089341986.1574258294045--

知道为什么会发生这种情况吗?

【问题讨论】:

    标签: spring mime


    【解决方案1】:

    这种行为实际上植根于 javax.mail 包,它执行了一些编码检测巫毒术并最终导致了这种行为。如果显式设置 utf-8 字符集从而避免自动检测,则内容甚至会采用 base64 编码。

    我们现在确实制定了一种解决方法,将 unicode-codepoints 显式编码为 html-entities 以用于 html-attachments。 wenn 所有的 unicode-codepoints 都以这种方式编码,javax.mail 会将整个内容视为 us-ascii 并且根本不进行特殊编码。

    【讨论】:

      猜你喜欢
      • 2012-05-14
      • 2012-10-12
      • 2010-09-22
      • 2019-11-25
      • 2014-07-19
      • 1970-01-01
      • 1970-01-01
      • 2013-12-14
      • 1970-01-01
      相关资源
      最近更新 更多