電子郵件客戶端如何讀取內容類型標頭進行編碼? (How does an email client read the content-type headers for encoding?)


問題描述

電子郵件客戶端如何讀取內容類型標頭進行編碼? (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.

(by deitchMax)

參考文件

  1. How does an email client read the content‑type headers for encoding? (CC BY‑SA 2.5/3.0/4.0)

#character-encoding #email #imap #smtp






相關問題

android webview顯示windows-1250字符集html的問題 (Trouble with android webview displaying windows-1250 charset html)

SQL Server 2008:字符編碼 (SQL Server 2008 : Character encoding)

刪除不可打印的字符 (Removing non-printable character)

電子郵件客戶端如何讀取內容類型標頭進行編碼? (How does an email client read the content-type headers for encoding?)

帶有 iText 7 的 PDF 中的希臘字符 (Greek characters in PDF with iText 7)

如何在 C 字符串中的文本或字母中添加下標字符? (How to add a subscript character to text or a letter in a C string?)

來自 URL 編碼問題的 NSArray (NSArray from URL encoding problem)

網絡上有免費提供的 HTML URL 編碼功能嗎?(在 C 中實現) (Is there any HTML URL encoding function freely available on web?? (Implementation in C))

讀取未知編碼的文本行 (Reading lines of text in unknown encoding)

Python - 以 Python 可以使用的格式編碼外來字符的方法? (Python - Way to encode foreign characters in format Python can work with?)

決定 HTTP 標頭的字符集。我應該簡單地把 utf-8 和 fuggedaboutit 放在一起嗎? (Deciding charset for HTTP Headers. Should i simply put utf-8 and fuggedaboutit?)

如何在 python 中將原始 unicode 轉換為 utf8-unicode? (How to convert raw unicode to utf8-unicode in python?)







留言討論