問題描述
電子郵件客戶端如何讀取內容類型標頭進行編碼? (How does an email client read the content‑type headers for encoding?)
可以發送具有不同內容類型的電子郵件:text/html、text/plain、mime 等。還可以使用不同的編碼,包括(根據 RFC)標題字段:us‑ascii , utf8 等。
雞和蛋的問題你是怎麼解決的?content‑type
標頭只是幾個標頭之一。如果標頭可以是任何編碼,如果郵件服務器或客戶端不知道標頭本身的編碼是什麼,它如何知道如何讀取 content‑type
標頭?
如果第一行必須是 content‑type
並且必須採用預先約定的編碼(例如 ascii),我可以看到它,但事實並非如此。
參考解法
方法 1:
Headers are defined to be in ascii. They can be in utf‑8 if agreed to out of band, such as via the smtp or imap utf‑8 capability extensions.
Internationalization in headers is performed via "encoded words", where the encoding is part of the header data. (This looks like a string such as =?iso8859‑1?q?sample_header_data?=). See rfc2047.
Content Type headers do not apply to headers themselves, only the body content.