xref: /dflybsd-src/contrib/file/magic/Magdir/rtf (revision 970935fd377c084648da946d7d7e6d0286f5f89a)
1327e51cbSPeter Avalos
2327e51cbSPeter Avalos#------------------------------------------------------------------------------
3*970935fdSSascha Wildner# $File: rtf,v 1.9 2020/12/12 20:01:47 christos Exp $
4327e51cbSPeter Avalos# rtf:	file(1) magic for Rich Text Format (RTF)
5327e51cbSPeter Avalos#
6327e51cbSPeter Avalos# Duncan P. Simpson, D.P.Simpson@dcs.warwick.ac.uk
7c990e5baSDaniel Fojt# Update:	Joerg Jenderek
8c990e5baSDaniel Fojt# URL:		https://en.wikipedia.org/wiki/Rich_Text_Format
9c990e5baSDaniel Fojt# Reference:	http://www.snake.net/software/RTF/RTF-Spec-1.7.rtf
10c990e5baSDaniel Fojt#		http://www.kleinlercher.at/tools/Windows_Protocols/Word2007RTFSpec9.pdf
11c990e5baSDaniel Fojt0	string		{\\rtf
12c990e5baSDaniel Fojt# skip DROID fmt-355-signature-id-522.rtf by looking for valid version
13c990e5baSDaniel Fojt>5	ubyte		!0xAB
14c990e5baSDaniel Fojt# skip also \ in DROID fmt-50-signature-id-158.rtf by looking for valid version
15c990e5baSDaniel Fojt>>5	ubyte		!0x5C		Rich Text Format data
1679343712SPeter Avalos!:mime	text/rtf
17c990e5baSDaniel Fojt!:apple	????RTF
18c990e5baSDaniel Fojt!:ext	rtf
19c990e5baSDaniel Fojt>>>0	use		rtf-info
20c990e5baSDaniel Fojt#	display information like version, language and code page of RTF
21c990e5baSDaniel Fojt0	name		rtf-info
22c990e5baSDaniel Fojt# 1 mostly, 2 for newer Pocket Word documents, space for test like fdo78502.rtf, { for some urtf
23c990e5baSDaniel Fojt>5	ubyte		!0x7b		\b, version %c
24c990e5baSDaniel Fojt# The word for character set must precede any text or most other control words
25c990e5baSDaniel Fojt>6	string		\\mac		\b, Apple Macintosh
26c990e5baSDaniel Fojt>6	string		\\pc
27c990e5baSDaniel Fojt# control word \pca
28c990e5baSDaniel Fojt>>9	ubyte		=0x61		\b, IBM PS/2, code page 850
29c990e5baSDaniel Fojt>>9	ubyte		!0x61		\b, IBM PC, code page 437
30c990e5baSDaniel Fojt# unknown character set or ANSI later after control words like
31c990e5baSDaniel Fojt# \adeflang1025 \info \title \author \category \manager
32c990e5baSDaniel Fojt# "Burow, Steffanie - Im Tal des Schneeleoparden.rtf"
33c990e5baSDaniel Fojt#>6	search/105	\\ansi		\b, ANSI
34c990e5baSDaniel Fojt>6	search/502	\\ansi		\b, ANSI
35c990e5baSDaniel Fojt>6	default		x		\b, unknown character set
36*970935fdSSascha Wildner# look for explicit codepage keyword
37c990e5baSDaniel Fojt# "Burow, Steffanie - Im Tal des Schneeleoparden.rtf"
38c990e5baSDaniel Fojt#>5	search/110	\\ansicpg
39c990e5baSDaniel Fojt>5	search/500	\\ansicpg
40c990e5baSDaniel Fojt# skip unknown or buggy codepage string 0 like in fdo78502.rtf
41c990e5baSDaniel Fojt>>&0	ubyte		!0x30		\b, code page
42c990e5baSDaniel Fojt# codepage string: 437~United States IBM, ..., 1252~WesternEuropean, ..., 57011~Punjabi
43c990e5baSDaniel Fojt>>>&-1		string	x		%-.3s
44c990e5baSDaniel Fojt# skip space or \ and display possible 4th digit of code page string
45c990e5baSDaniel Fojt>>>&2		ubyte	>0x2F
46c990e5baSDaniel Fojt>>>>&-1		ubyte	<0x3A		\b%c
47c990e5baSDaniel Fojt# possible 5th digit of code page string
48c990e5baSDaniel Fojt>>>>>&0		ubyte	>0x2F
49c990e5baSDaniel Fojt>>>>>>&-1	ubyte	<0x3A		\b%c
50c990e5baSDaniel Fojt# look again at version byte to use default clause
51c990e5baSDaniel Fojt>5	ubyte		x
52c990e5baSDaniel Fojt# Default language ID for South Asian/Middle Eastern text
53c990e5baSDaniel Fojt# language ID: 1025, ..., 1065~Persian, ..., 2057~English_UnitedKingdom, ..., 58380~French_NorthAfrica
54c990e5baSDaniel Fojt# Readme-0.72-Persian.rtf
55c990e5baSDaniel Fojt#>6	search/1	\\adeflang	\b, default middle east language ID
56c990e5baSDaniel Fojt>>6	search/497	\\adeflang	\b, default middle east language ID
57c990e5baSDaniel Fojt# https://docs.microsoft.com/en-us/openspecs/office_standards/ms-oe376/6c085406-a698-4e12-9d4d-c3b0ee3dbc4a
58c990e5baSDaniel Fojt>>>&0	string		x		%.4s
59c990e5baSDaniel Fojt# skip \ and NL and show possible 5th digit of language string
60c990e5baSDaniel Fojt>>>&4	ubyte		>0x2F
61c990e5baSDaniel Fojt>>>>&-1	ubyte		<0x3A		\b%c
62c990e5baSDaniel Fojt# else look for default language to be used when the \plain control word is encountered
63c990e5baSDaniel Fojt>>6	default		x
64c990e5baSDaniel Fojt# "Burow, Steffanie - Im Tal des Schneeleoparden.rtf"
65c990e5baSDaniel Fojt#>>>6	search/127	\\deflang
66c990e5baSDaniel Fojt>>>6	search/505	\\deflang
67c990e5baSDaniel Fojt>>>>&0	string		>0		\b, default language ID %-.4s
68c990e5baSDaniel Fojt# possible 5th digit of language string
69c990e5baSDaniel Fojt>>>>&4		ubyte	>0x2F
70c990e5baSDaniel Fojt>>>>>&-1	ubyte	<0x3A		\b%c
71c990e5baSDaniel Fojt
72c990e5baSDaniel Fojt# Reference:	http://latex2rtf.sourceforge.net/rtfspec_63.html
73c990e5baSDaniel Fojt# Note:		no real world example found
74c990e5baSDaniel Fojt0	string		{\\urtf		Rich Text Format unicoded data
75c990e5baSDaniel Fojt!:mime	text/rtf
76c990e5baSDaniel Fojt#!:apple	????RTF
77c990e5baSDaniel Fojt!:ext	rtf
78c990e5baSDaniel Fojt>1	use		rtf-info
79c990e5baSDaniel Fojt
80c990e5baSDaniel Fojt# URL:		https://en.wikipedia.org/wiki/Microsoft_Word
81c990e5baSDaniel Fojt# Reference:	http://fileformats.archiveteam.org/wiki/Microsoft_Word
82c990e5baSDaniel Fojt# Note:	called by TrID "Pocket Word document"
83c990e5baSDaniel Fojt#	by PlanMaker "Pocket Word-Handheld PC" for pwd
84c990e5baSDaniel Fojt#	by PlanMaker "Pocket Word-Pocket PC" for psw
85c990e5baSDaniel Fojt0	string		{\\pwd		Pocket Word document or template
86c990e5baSDaniel Fojt# by SoftMaker Office	http://extension.nirsoft.net/pwd
87c990e5baSDaniel Fojt#!:mime	application/msword
88c990e5baSDaniel Fojt# https://reposcope.com/mimetype/application/x-pocket-word
89c990e5baSDaniel Fojt!:mime	application/x-pocket-word
90c990e5baSDaniel Fojt# PWD for Handheld PC variant and PSW for Pocket PC variant
91c990e5baSDaniel Fojt# PWT for template
92c990e5baSDaniel Fojt!:ext	pwd/psw/pwt
93c990e5baSDaniel Fojt>0	use		rtf-info
94c990e5baSDaniel Fojt
95