如何防止 TMail 丢弃希伯来语电子邮件的最后一个字母?
我正在尝试处理一些包含以 Windows-1255 编码的希伯来语字符的传入电子邮件。
一些示例内容:
From: =?windows-1255...
Subject: =?windows-1255...
...
--Boundary_(ID_/GX/qGlPt4gpL8Dqc2zQQg)
Content-type: text/plain; charset="windows-1255"
Content-transfer-encoding: quoted-printable
...
主题应该是“שאלה - לאור צדוק”,但实际上是“שאלה - לאור צדו"。即最后一个字符被删除。From
名称也是如此。
我发现这个问题在 Iconv 列表中,它描述了相同的问题。最终的结论如下:
In the original code snippet, there's a call to
iconv(the_iconv, NULL, NULL, &utf8, &bytes_written);
missing at the end.
这与 Ruby Iconv 文档(我已经 复制到此 Gist),它强调了在输入末尾添加 nil
的重要性。
我的代码中没有任何地方使用 Iconv 的 Array 或块版本;我总是使用 Iconv.iconv 辅助方法,该方法添加了 nil 。我已经检查了 TMail 源代码,它使用相同的 Iconv.iconv
帮助程序,
有人见过这样的东西吗?
I am trying to process some incoming emails that contain Hebrew characters encoded in Windows-1255.
Some example content:
From: =?windows-1255...
Subject: =?windows-1255...
...
--Boundary_(ID_/GX/qGlPt4gpL8Dqc2zQQg)
Content-type: text/plain; charset="windows-1255"
Content-transfer-encoding: quoted-printable
...
The subject is supposed to be "שאלה - ליאור צדוק", but is instead "שאלה -
ליאור צדו". That is, the last character is dropped. The same is true of the From
name.
I found this issue on the Iconv list, which describes the same issue. The final word is as follows:
In the original code snippet, there's a call to
iconv(the_iconv, NULL, NULL, &utf8, &bytes_written);
missing at the end.
This jives with the Ruby Iconv documentation (which I've copied to this Gist), which emphasizes the importance of adding nil
to the end of the input.
Nowhere in my code do I use the Array
or block versions of Iconv; I always use the Iconv.iconv
helper method, which adds the nil
for you. I've checked the TMail source and it uses the same Iconv.iconv
helper.
Has anyone seen anything like this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
嗯,这实际上比我想象的要容易。我曾尝试将
nil
添加到我的Iconv.iconv
调用的末尾,但没有成功。我没有尝试过对结果调用join
。因此,最终的正确结果是Well, that was actually easier than I thought. I had tried adding
nil
to the ends of myIconv.iconv
calls to no avail. What I hadn't tried was callingjoin
on the result. Thus, the final correct result is