douwei1904 2015-12-11 16:05
浏览 29
已采纳

mime.quotedprintable无法解码此消息

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条回答 默认 最新

  • dongzaobei0942 2015-12-11 16:39
    关注

    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.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 python使用pulp线性优化时报错
  • ¥15 开源或低价数据中台哪个最好
  • ¥15 arduino编程出现字符串疑似覆盖现象
  • ¥15 我的b站在没有碰到屏幕的情况下偶尔会自动跳出进度条,就像在屏幕上点了一下一样,但我并没有点。而且视频进度并没有变。这可能是什么原因造成的?
  • ¥30 STK matlab python仿真
  • ¥15 关于IMageEnView 图标定位问题
  • ¥20 求解答(matlab)
  • ¥30 ffmpeg库使用过程中遇到的问题
  • ¥15 pyqt5 中python如何通过Qtwebchannel主动发消息给web前端
  • ¥15 关于HTML中title获取xml内容的问题