Jump to content

Rich Text Format

From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by JWWalker (talk | contribs) at 21:24, 23 June 2006 (make sample RTF work in TextEdit on Mac). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.

The Rich Text Format (often abbreviated to RTF) is a proprietary document file format developed and owned by Microsoft since 1987 for cross-platform document interchange. Most word processors are able to read and write RTF documents. Unlike most of the word processing formats, RTF is human-readable.

Sample RTF document

As an example, the following RTF code:

{\rtf1\ansi{\fonttbl\f0\fswiss Helvetica;}\f0 Hello!\par This is some {\b bold} text.\par }

would be rendered like this when read by an appropriate word processor:

Hello!
This is some bold text.

A backslash (\) starts an RTF control code. The \par control code indicates a new line, and \b switches to a bold typeface. Braces ({ and }) define a group; the example uses a group to limit the scope of the \b control code. Everything else will be treated as clear text, or the text to be formatted. A valid RTF document is a group starting with the \rtf control code.

Character encoding

RTF is a 7-bit format. That would limit it to ASCII, but RTF can encode characters beyond ASCII by escape sequences. The character escapes are of two types: codepage escapes and Unicode escapes. In a codepage escape, two hexadecimal digits following an apostrophe are used for denoting a character taken from a Windows codepage. For example, if control codes specifying Windows-1256 are present, the sequence \'c8 will encode the Arabic letter beh (ب).

If a Unicode escape is required, the control word \u is used, followed by a 16-bit signed decimal integer giving the Unicode codepoint number. For the benefit of programs without Unicode support, this must be followed by the nearest representation of this character in the specified code page. For example, \u1576? would give the Arabic letter beh, specifying that older programs which do not have Unicode support should render it as a question mark instead.

Common implementations

Most word processing software supports RTF format import and export, which makes it one "common" format between otherwise incompatible word processing software.

Previous versions of the WordPad editor in Microsoft Windows created RTF files by default. The current version can view and edit RTF files. It defaulted to the Microsoft Word 6.0 file format, but write support for Word documents was dropped in a security update by default.

The open-source word processors AbiWord and OpenOffice.org can view and edit RTF files.

The default editor for Mac OS X, TextEdit, can also view and edit RTF files.

See also