japanese email subject encoding

后端 未结 9 1555
天命终不由人
天命终不由人 2020-12-15 08:02

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)

9条回答
  •  无人及你
    2020-12-15 08:56

    First of all you should be using:

    Encoding.GetEncoding("ISO-2022-JP")

    to convert your subject line into bytes that will be processed by Convert.ToBase64String().

    =?ISO-2022-JP?B?TEXTTEXT...?= tells the receiving mail client which encoding was used on the sender's side to convert japanese "letters" into a byte stream.

    Currently you're using UTF-16 to encode, but specifying ISO-2022-JP to decode. These are obviously two different encodings, I guess, just like ISO-8859-1 is different from Unicode (most extended western-europe chars are represented by one byte in ISO-XXX, but two bytes in Unicode).

    I'm not sure what you mean about UTF-8 being second-class citizen. As long as the receiving mail client understands UTF-8 and is able to convert it to the current japanese locale, everything is fine.

提交回复
热议问题