WordPerfect 5.0 and 5.1 for DOS (and 5.1 and 5.2 for Windows) write files with major version 0 in the WPC header. After the header comes a prefix of packets, then, at the document pointer, the document itself: one stream of text bytes mixed with function codes, as WordPerfect’s Reveal Codes view shows it. This page follows libwpd; codes that libwpd does not name are listed as unknown. The bytes inside each group and packet are on the 5.x function data page.
Prefix packets
The prefix starts at offset 16 and is a chain of index blocks. Each block is 50 bytes: a 10-byte block header and four 10-byte packet entries. Numbers are little-endian.
| Offset | Size | Field | Meaning |
|---|---|---|---|
0 | 2 | Type | 0xFFFB for an index block. |
2 | 2 | Number of indexes | 5 (the block header and four packets). |
4 | 2 | Block size | 50. |
6 | 4 | Next block | File offset of the next index block, or 0 for the last. |
10 | 10 × 4 | Packet entries | Each: type (2 bytes), data size (4), data offset in the file (4). |
A packet type of 0 or 0xFFFF is an unused entry. libwpd treats types
between 0x0300 and 0xFFFA as a sign of corruption.
| Packet type | Contents |
|---|---|
| 2 | List of fonts used (WordPerfect 5.0). |
| 7 | Font name string pool: the font names that font changes refer to. |
| 8 | Graphics information: the pictures in graphics boxes. |
| 15 | List of fonts used (WordPerfect 5.1). |
Other packet types exist (printer and document settings, for example); their numbers and contents are not public.
The document area
Each byte of the document area is read by its value:
| Bytes | Meaning |
|---|---|
0x00, 0x7F, 0xFF | Not used; ignored. |
0x01–0x1F | Control characters: 0x0A hard return, 0x0B soft page break (read as a space), 0x0C hard page break, 0x0D soft return (the end of a wrapped line, read as a space). The others are not documented. |
0x20–0x7E | ASCII text. |
0x80–0xBF | Single-byte functions. |
0xC0–0xCF | Fixed-length function groups. |
0xD0–0xFE | Variable-length function groups. |
Single-byte functions
| Code | Function |
|---|---|
0x8C | Hard return that is also a soft page break. |
0x90 | Deletable return at the end of a line. |
0x93 | Invisible return in a line. |
0x94 | Invisible return at the end of a line. |
0x95 | Invisible return at the end of a page. |
0x99 | Dormant hard return. |
0xA0 | Hard (non-breaking) space. |
0xA9, 0xAA, 0xAB | Hard hyphen in a line, at the end of a line, at the end of a page. |
0xAC, 0xAD, 0xAE | Soft hyphen in a line, at the end of a line, at the end of a page. |
The other codes from 0x80 to 0xBF are single-byte
functions whose meanings are not public.
Fixed-length function groups
A fixed-length group starts and ends with its code byte, with a fixed number of bytes between. The total sizes, both code bytes included:
| Code | Size | Function | Contents |
|---|---|---|---|
0xC0 | 4 | Extended character | Character number, character set. |
0xC1 | 9 | Tab, centre or flush right | Starts with a tab type. |
0xC2 | 11 | Indent | Starts with 0 left indent, 1 left and right indent. |
0xC3 | 3 | Attribute on | One attribute number. |
0xC4 | 3 | Attribute off | One attribute number. |
0xC5 | 5 | Unknown | – |
0xC6 | 6 | Unknown | – |
0xC7 | 7 | Unknown | – |
0xC8 | 4 | Unknown | – |
0xC9 | 5 | Unknown | – |
0xCA | 6 | Unknown | – |
0xCB | 6 | Unknown | – |
0xCC | 8 | Unknown | – |
0xCD | 10 | Unknown | – |
0xCE | 10 | Unknown | – |
0xCF | 12 | Unknown | – |
Bold text, for example, is C3 0C C3, the text, then
C4 0C C4.
Variable-length function groups
A variable-length group starts with its code, a sub-code and a 16-bit length, and ends with the same length, sub-code and code, so it can be read in either direction:
code subcode length(2) data… length(2) subcode code
The length is the number of data bytes plus 3. According to libwpd, the codes from
0xD0 to 0xDF, 0xE1 and 0xFE are
the documented ones.
| Code | Group | Sub-codes |
|---|---|---|
0xD0 | Page format | 1 left and right margins; 2 line spacing; 4 tab set; 5 top and bottom margins; 6 justification; 7 suppress page features (flags); 11 paper size and type (form) |
0xD1 | Font | 0 colour; 1 font change (font and size, the name in the font packet) |
0xD2 | Definition | 11 define a table |
0xD4 | Format | 0 end of page |
0xD5 | Header or footer | 0 header A, 1 header B, 2 footer A, 3 footer B; the data says on which pages (bit 1 all, 2 odd, 4 even) and holds the text |
0xD6 | Footnote or endnote | 0 footnote, 1 endnote; the data holds the note’s text |
0xDA | Box | 0 figure, 1 table box, 2 text box, 3 user box, 4 equation, 5 horizontal line, 6 vertical line |
0xDC | Table end of line | 0 start of a cell, 1 start of a row, 2 end of the table |
0xDD | Table end of page | 1 start of a row at a page break, 2 end of the table at a page break, 3 start of a row at a hard page break |
Groups 0xD3, 0xD7 to 0xD9, 0xDB,
0xDE, 0xDF, 0xE1 and 0xFE exist but
their contents are not described by libwpd, which skips them using their length.
Suppress page features
Flags of the suppress sub-code of 0xD0: 0x01 page number, 0x02 page
number at the bottom, 0x04 header A, 0x08 header B, 0x10 footer A, 0x20 footer B, 0x80
the code is not at the top of the page.
Attributes
| N | Attribute | N | Attribute |
|---|---|---|---|
| 0 | Extra large | 8 | Italic |
| 1 | Very large | 9 | Shadow |
| 2 | Large | 10 | Redline |
| 3 | Small | 11 | Double underline |
| 4 | Fine | 12 | Bold |
| 5 | Superscript | 13 | Strikeout |
| 6 | Subscript | 14 | Underline |
| 7 | Outline | 15 | Small caps |
Tab types
First data byte of the 0xC1 group:
| Value | Meaning |
|---|---|
0x00 | Left tab |
0x08 | Decimal tab |
0x09 | Right tab |
0x0C | Flush right |
0x10 | Back tab |
0x18 | Centre on the current position |
0x19 | Centre tab |
0x1C | Centre between the margins |
Character sets
Characters outside ASCII are written as extended characters
(C0 character set C0) in WordPerfect’s own character sets:
| Set | Contents | Set | Contents |
|---|---|---|---|
| 0 | ASCII | 7 | Maths and science, extended |
| 1 | International 1 (accented Latin letters) | 8 | Greek |
| 2 | International 2 (diacritics) | 9 | Hebrew |
| 3 | Box drawing | 10 | Cyrillic |
| 4 | Typographic symbols | 11 | Japanese (kana) |
| 5 | Iconic symbols | 13 | Arabic |
| 6 | Maths and science | 14 | Arabic script |
Set 12 is not used in 5.x. libwpd has a table mapping every character of these sets to Unicode.
Example
48 65 6C 6C 6F 20 C3 0C C3 77 6F 72 6C 64 C4 0C C4 0A
“Hello ”, bold on, “world”, bold off, hard return: “Hello world” on its own line.