コンテンツへスキップ
uencoder

MIME Encoding

MIME(Multipurpose Internet Mail Extensions)エンコーディングは、メールで非 ASCII テキストやバイナリ添付を運ぶ仕組みを定義する。Base64 と Quoted-Printable のコンテンツ転送符号化を含む。

目的

当初 7 ビット ASCII しか扱えなかった SMTP を拡張し、任意のバイト列や多言語テキストを運べるようにする。

メカニズム

Content-Transfer-Encoding ヘッダが符号化を宣言する。7bit/8bit/binary はそのまま通し、base64 は任意のバイナリを符号化し、quoted-printable は印字不能文字だけをエスケープする。Content-Type ヘッダは MIME タイプと境界を宣言する。

ユースケース

  • メール添付の転送
  • HTTP multipart/form-dataアップロード
  • Usenetバイナリ添付
  • S/MIME暗号化メール

例

  • 入力
    Content-Transfer-Encoding: base64
    Output
    SGVsbG8=

    The body is Base64-encoded as declared

よくあるエラー

Decoding a MIME attachment while ignoring the Content-Transfer-Encoding header
Decode according to the header first, then interpret the result using the charset

関連用語

関連ツール

References