1

我无法理解这里发生了什么。我收到一封带有以下 UTF8 编码主题行的电子邮件,但我无法将其转换为以下编码。

未转换:Переход на прямые договоры узаконен!

已转换:=?UTF-8?B?0J/QtdGA0LXRhdC+0LQg0L3QsCDQv9GA0Y/QvNGL0LUg?= =?UTF-8?B?0LTQvtCz0L7QstC+0YDRiyDRg9C30LDQutC+0L3QtdC9IQ==?=

你能帮我理解这里发生了什么吗?上面的 MIME 编码到底是什么?转换为 UTF8 字符串与我在上面看到的不匹配。

4

1 回答 1

0

Those characters are not covered with ascii and encoded in UTF-8. Moreover, the email subject MIME encoding was done using UTF-8 (RFC2047).

Easiest solution for this is, using npm rfc2047 library. Refer the sample code below.

const rfc2047 = require('rfc2047');
let subjectLine = "=?UTF-8?Q?Votre_demande_de?=\n =?UTF-8?Q?_a_=C3=A9t=C3=A9_approuv=C3=A9e!?=";
let frenchSubjectLine = rfc2047.decode(subjectLine);
console.log("FR subject line after decoding: [" + frenchSubjectLine + "]");

Output is

FR subject line after decoding: [Votre demande de a été approuvée!]
于 2020-12-21T18:36:10.327 回答