file in abyss
フォーマット一覧へ戻る

Document

RTF Rich Text Format

書式付きテキスト文書形式。Wordなど多くのエディタで開け、通常は{\\rtfから始まります。

Extensions .rtf
MIME application/rtf, text/rtf

マジックナンバー

ファイルを解析
オフセット 0 RTF header
7B 5C 72 74 66
{\rtf

構造

  1. Header
  2. Font table
  3. Control words
  4. Text groups

注意点

  • RTFはテキスト形式ですが制御語が多く、埋め込みオブジェクトを含む場合があります。

判定コード例

SIGNATURE = bytes.fromhex("7b5c727466")
OFFSET = 0

def is_rtf(path: str) -> bool:
    with open(path, "rb") as f:
        f.seek(OFFSET)
        head = f.read(len(SIGNATURE))
    return head == SIGNATURE

実践的な使い方

ユースケース

Rich Text Format はデータ交換、インポート/エクスポート、パーサのテスト、検証ワークフローで使われます。エンコーディング・区切り文字・バージョン・コンテナ構造が実装の挙動を変えることがあります。

よくある判定ミス

  • .rtf という拡張子だけではファイルの中身を保証できません。アップロードや変換の処理では、拡張子・MIMEタイプ・先頭バイト・形式固有の構造チェックを組み合わせるべきです。
  • Rich Text Format は 7B 5C 72 74 66 のようなシグネチャで始まりますが、関連するコンテナや破損ファイルでは追加の検証が必要になる場合があります。

セキュリティ上の注意

文書形式はスクリプト・添付・マクロ・外部参照を含むことがあります。プレビューや変換はサンドボックス化し、信頼できないファイルを直接開かないでください。

サンプルの活用

11 個のサンプルで、先頭バイト判定・パーサのエラー・アップロード上限・ダウンロード挙動をテストできます。

サンプルファイル

11 / 11 files
Sample Traits Size Source / license / SHA-256
Doc

Blue Sky RTF

Blue Sky RTF is a Rich Text Format sample based on Wikimedia Commons. It can be used to test downloads, parsers, previews, and file type detection.

01-blue-sky.rtf
Type Sample
Small file
184 B
SHA-256 ca46ce089c878dfc268d903cb18e634fe502455a2500742864a48707e63c6ddc
Download
Doc

Flower Garden RTF

Flower Garden RTF is a Rich Text Format sample based on Wikimedia Commons. It can be used to test downloads, parsers, previews, and file type detection.

02-flower-garden.rtf
Type Sample
Small file
242 B
SHA-256 915800782ddea2e4e4bcf64c1de1ea6041ce385f99ce3fd48943aa4de28289aa
Download
Doc

Navy Blue Sky RTF

Navy Blue Sky RTF is a Rich Text Format sample based on Wikimedia Commons. It can be used to test downloads, parsers, previews, and file type detection.

03-navy-blue-sky.rtf
Type Sample
Small file
249 B
SHA-256 14e55c9ca5e4611245aeafb27928a0a0f2df1e752e889115a64cca98c1155702
Download
Doc

Nature of the Sky RTF

Nature of the Sky RTF is a Rich Text Format sample based on Wikimedia Commons. It can be used to test downloads, parsers, previews, and file type detection.

04-nature-sky.rtf
Type Sample
Small file
256 B
SHA-256 b710eefc8fb8b2966bed7a4d98f0a6c213238e9ee43fe6423ffba92b2cc5e901
Download
Doc

Sky Landscape RTF

Sky Landscape RTF is a Rich Text Format sample based on Wikimedia Commons. It can be used to test downloads, parsers, previews, and file type detection.

05-sky-landscape.rtf
Type Sample
Small file
342 B
SHA-256 332089461015ea27eab1e0d60f51d146d349973d9545d65e46164fc47e7ec621
Download
Doc

Starry Sky RTF

Starry Sky RTF is a Rich Text Format sample based on Wikimedia Commons. It can be used to test downloads, parsers, previews, and file type detection.

06-starry-sky.rtf
Type Sample
Small file
268 B
SHA-256 c3222088a1b69243cf944ab189e61ca4e487077d0f95be7f952adb471d96fd5d
Download
Doc

Blue Night Sky RTF

Blue Night Sky RTF is a Rich Text Format sample based on Wikimedia Commons. It can be used to test downloads, parsers, previews, and file type detection.

07-blue-night-sky.rtf
Type Sample
Small file
313 B
SHA-256 ffd9fb1fcb1233b02129b1ff29b537a7f10b5d8f1d78a842911a44a68ba768b5
Download
Doc

Hibiscus Flower RTF

Hibiscus Flower RTF is a Rich Text Format sample based on Wikimedia Commons. It can be used to test downloads, parsers, previews, and file type detection.

08-hibiscus-flower.rtf
Type Sample
Small file
445 B
SHA-256 4d12c8526787593fb26dca21259ee6d13c22ad03f13cae14df94cb3beb794833
Download
Doc

Arctic Sky RTF

Arctic Sky RTF is a Rich Text Format sample based on Wikimedia Commons. It can be used to test downloads, parsers, previews, and file type detection.

09-arctic-sky.rtf
Type Sample
Small file
387 B
SHA-256 9c14832a446200557a1ff38c9a0a066f1cfcfd7c635fa48301f894bdaca4dd15
Download
Doc

Sunset Rays RTF

Sunset Rays RTF is a Rich Text Format sample based on Wikimedia Commons. It can be used to test downloads, parsers, previews, and file type detection.

10-sunset-rays.rtf
Type Sample
Small file
414 B
SHA-256 390d4af0959bf64bc2020ab4ca4eead0f7c14a3c55330a9bd6532b39f3dedb1e
Download
Doc

NASA Blue Marble RTF

NASA Blue Marble RTF is a Rich Text Format sample based on NASA Image and Video Library. It can be used to test downloads, parsers, previews, and file type detection.

nasa-blue-marble-2012-east.rtf
Type Sample
Small file
720 B
SHA-256 e5b07989f55a9da71bfdb9fdcd1e17ea45aea807d25571cca6da9886e0fc908c
Download

よくある質問

Rich Text Format のマジックナンバー(ファイルシグネチャ)は?

Rich Text Format ファイルはバイトシグネチャ 7B 5C 72 74 66 ("{\rtf") で始まります。拡張子に頼らず、この先頭バイトを読み取って形式を判定してください。

Rich Text Format のMIMEタイプは?

Rich Text Format のMIMEタイプは application/rtf, text/rtf です。

Rich Text Format の拡張子は?

Rich Text Format ファイルは .rtf 拡張子を使います。拡張子は慣習にすぎず中身を保証しないため、シグネチャや構造のチェックと組み合わせてください。

関連フォーマット