英文:
mime.quotedprintable having trouble decoding this message
问题
我正在尝试解码一条消息,该消息不完全符合“Quoted Printable String”的规范。
下面的代码片段中,有一个=
应该是=3D
,这在多个地方都出现了。实际上,这里发生了两个错误:
------=_Part_7575500_2105086112.1449628640342
Content-Type: text/html; charset="UTF-8"
我使用以下代码进行解码:
qpr := quotedprintable.NewReader(msg.Body)
cleanBody, err := ioutil.ReadAll(qpr)
结果出现错误:(在第一个=之后出现了下划线)
quotedprintable: invalid hex byte 0x5f
请问我该如何修复这个问题?谢谢。
英文:
I am trying to decode a message which doesn't completely conform to the Quoted Printable String
idea.
One of the snippets as shown below has an =
where should be an =3D
this occurs in a number of places. In fact there are two offences occurring here:
------=_Part_7575500_2105086112.1449628640342
Content-Type: text/html; charset="UTF-8"
I'm decoding with the as follows:
qpr := quotedprintable.NewReader(msg.Body)
cleanBody, err := ioutil.ReadAll(qpr)
The resulting error is: (complaining about the _ after first =)
quotedprintable: invalid hex byte 0x5f
How can I fix get this to work please? Thank you.
答案1
得分: 0
你不仅仅有 quoted-printable 数据,它还是 MIME 多部分消息的一部分。=_
模式的使用是因为它在 quoted-printable 消息中永远不会出现。
使用 multipart.Reader
来获取每个部分的内容。
英文:
You don't just have quoted-printable data, it's part of a MIME multipart message. The =_
pattern is specifically used because it can never occur in a quoted-printable message.
Use a multipart.Reader
to get the contents of each part.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论