日本电子邮件主题编码 [英] japanese email subject encoding

查看:370
本文介绍了日本电子邮件主题编码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Aparently,编码日本电子邮件是有点挑战性的,这我慢慢发现自己。如果有任何专家(即使是经验有限将做),我可以请有一些指引,如何去做,如何测试,以及如何验证?

Aparently, encoding japanese emails is somewhat challenging, which I am slowly discovering myself. In case there are any experts (even those with limited experience will do), can I please have some guidelines as to how to do it, how to test it and how to verify it?

请记住,我从来没有踏足附近日本各地,它只是我在开发产品用于在那里,在其他地方。

Bear in mind that I've never set foot anywhere near Japan, it is simply that the product I'm developing is used there, among other places.

什么(我认为)我知道到目前为止是以下几点:结果
- 日本的邮件应编码ISO-2022-JP,日本JIS代码页50220或可能SHIFT_JIS代码页932结果
- 电子邮件传输编码应设置为Base64为纯文本和7位对HTML结果
- 电子邮件主题应分别编码为开始= ISO-2022-JP b'? (不知道这是应该的意思)。我试着用编码

What (I think) I know so far is following:
- Japanese emails should be encoded in ISO-2022-JP, Japanese JIS codepage 50220 or possibly SHIFT_JIS codepage 932
- Email transfer encoding should be set to Base64 for plain text and 7Bit for Html
- Email subject should be encoded separately to start with "=?ISO-2022-JP?B?" (don't know what this is supposed to mean). I've tried encoding the subject with

"=?ISO-2022-JP?B?" + Convert.ToBase64String(Encoding.Unicode.GetBytes(subject))



这基本上给出了编码字符串预期,但它不会出现在电子邮件程序结果
任何日本文本 - 我在Outlook 2003中进行测试时,Outlook Express和Gmail

which basically gives the encoded string as expected but it doesn't get presented as any japanese text in an email program
- I've tested in Outlook 2003, Outlook Express and GMail

任何帮助,将不胜感激。

Any help would be greatly appreciated

好了,发布简短的更新信息,这要归功于两个有用的答案,我已经设法得到正确的格式和编码。现在,展望给出了一些类似于正确的主题:???结果
= ISO-2022-JP B 6日语考试に各々の视点で语ってもらった6相当の?防水=

Ok, so to post a short update, thanks to the two helpful answers, I've managed to get the right format and encoding. Now, Outlook gives something that resembles the correct subject:
=?iso-2022-jp?B?6 Japanese test に各々の視点で語ってもらった。 6相当の防水?=

然而,在Outlook Express完全相同的电子邮件给主题是这样的:结果
=?ISO-2022-JP?B'6日语考试縺ォ蜷···陨也せ縺ァ隐槭▲縺ヲ繧ゅ我縺」縺溘·6逶ク蠖薙·髦イ豌エ?=

However, the exact same email in Outlook Express gives subject like this:
=?iso-2022-jp?B?6 Japanese test 縺ォ蜷・・・隕也せ縺ァ隱槭▲縺ヲ繧ゅi縺」縺溘・ 6逶ク蠖薙・髦イ豌エ?=

此外,在Outlook Express收件箱视图中查看时,电子邮件主题更是怪异,就像这样:结果
=?ISO-2022-JP?B'6日语考试??????????????? 6 ??????? =

Furthermore, when viewed in the Inbox view in Outlook Express, the email subject is even more weird, like this:
=?iso-2022-jp?B?6 Japanese test ??????????????? 6???????=

的Gmail似乎在类似的方式到Outlook,它看起来正确的是工作。

Gmail seems to be working in the similar fashion to Outlook, which looks correct.

我只是不能让我围绕这一头。

I just can't get my head around this one.

推荐答案

我一直在处理日本编码近20年,所以我可以用你的困难深表同情。我已经对每天发送数百封电子邮件给日本客户合作的网站,所以我可以与你分享什么对我们的工作。

I've been dealing with Japanese encodings for almost 20 years and so I can sympathize with your difficulties. Websites that I've worked on send hundreds of emails daily to Japanese customers so I can share with you what's worked for us.


  • 首先,不使用Shift键-JIS。我个人收到吨日本电子邮件和几乎没有他们使用Shift键-JIS编码。我觉得一个老(约Win 98的?)的Outlook Express版本编码使用Shift键-JIS传出邮件,但现在你只是看不到它。

  • First of all, do not use Shift-JIS. I personally receive tons of Japanese emails and almost never are they encoded using Shift-JIS. I think an old (circa Win 98?) version of Outlook Express encoded outgoing mail using Shift-JIS, but nowadays you just don't see it.

正如你已经想通了,你需要使用ISO-2022-JP作为编码至少任何云在邮件标题。这包括主题,收件人行,抄送行。 UTF-8也将在大多数情况下,的的它不会对雅虎日本的邮件工作,你可以想像,许多日本用户使用雅虎日本的邮件。

As you've figured out, you need to use ISO-2022-JP as your encoding for at least anything that goes in the mail header. This includes the Subject, To line, and CC line. UTF-8 will also work in most cases, but it will not work on Yahoo Japan mail, and as you can imagine, many Japanese users use Yahoo Japan mail.

您可以在电子邮件的正文中使用UTF-8,但建议您Base64编码,UTF-8编码的日语文本,并放进了身体,而不是原始的UTF-8文本。然而,在实践中,我认为,原始的UTF-8文本将正常工作,这些天,对于电子邮件的正文。

You can use UTF-8 in the body of the email, but it is recommended that you base64 encode the UTF-8 encoded Japanese text and put that in the body instead of raw UTF-8 text. However, in practice, I believe that raw UTF-8 text will work fine these days, for the body of the email.

正如我上面提到的,您需要在展望(交换)时,Outlook Express(IMAP / POP3)至少测试和雅虎日本网站的邮件。雅虎日本是最棘手的,因为我相信他们使用EUC其网页的编码,所以你需要遵循你的电子邮件的正确标准,否则将无法正常工作(ISO-2022-JP是发送电子邮件的日本标准)。

As I alluded to above, you need to at least test on Outlook (Exchange), Outlook Express (IMAP/POP3), and Yahoo Japan web mail. Yahoo Japan is the trickiest because I believe they use EUC for the encoding of their web pages, and so you need to follow the correct standards for your emails or they won't work (ISO-2022-JP is the standard for sending Japanese emails).

另外,你的主题行不应超过每行75个字符。也就是说,在的你在ISO-2022-JP和的base64编码过,没有转换之前75个字符75个字符的。如果超过75个字符,你需要打破你的编码主题分成多行,开始=?ISO-2022-JP?B'与结局?=每行。如果你不这样做,你的主题可能会被截断(根据电子邮件阅读器,并且还你的主题文本内容)。根据RFC 2047:

Also, your subject line should not exceed 75 characters per line. That is, 75 characters after you've encoded in ISO-2022-JP and base64, not 75 characters before conversion. If you exceed 75 characters, you need to break your encoded subject into multiple lines, starting with "=?iso-2022-jp?B?" and ending with "?=" on each line. If you don't do this, your subject might get truncated (depending on the email reader, and also the content of your subject text). According to RFC 2047:

一个'编码的字'可能不会很长超过75个字符,包括'字符集,编码,编码文本,并分隔符。如果需要编码除将适合在更多的文本编码字的75个字符,多'编码字的(由CRLF空格分隔)可能。用

"An 'encoded-word' may not be more than 75 characters long, including 'charset', 'encoding', 'encoded-text', and delimiters. If it is desirable to encode more text than will fit in an 'encoded-word' of 75 characters, multiple 'encoded-word's (separated by CRLF SPACE) may be used."


  • 这是一些示例PHP代码的主题编码:


 // Convert Japanese subject to ISO-2022-JP (JIS is essentially ISO-2022-JP)

 $subject = mb_convert_encoding ($subject, "JIS", "SJIS");

 // Now, base64 encode the subject

 $subject = base64_encode ($subject);

 // Add the encoding markers to the subject

 $subject = "=?iso-2022-jp?B?" . $subject . "?=";

 // Now, $subject can be placed as-is into the raw mail header.




  • 请参见RFC 2047为如何将电子邮件标题编码的完整描述

  • 这篇关于日本电子邮件主题编码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆