in reply to (Sorta OT) - Historic Wordperfect Conversion

I wrote a C program that converted from WP5 to sorta XML/XHTML ages ago -- I just reverse engineered the format, it wasn't too hard.

I would probably approach the problem the same way today -- write a piece of C code that does the conversion, rather than trying to simulate C code in Perl. Of course, your time line may prevent you from doing that.

--t. alex
Life is short: get busy!
  • Comment on Re: (Sorta OT) - Historic Wordperfect Conversion

Replies are listed 'Best First'.
Re:x2 (Sorta OT) - Historic Wordperfect Conversion
by grinder (Bishop) on Nov 07, 2003 at 18:17 UTC

    Heh, I did exactly the same thing! I still remember parts of the specs.

    There's a series of header blocks that define global properties of the document, and can be pretty much safely ignored. In the first dozen bytes or so there's a word (i.e. 16 bit value) that contains the offset in the file that is the first byte past the header blocks. I don't remember the offset, nor do I remember the endianness.

    After the header blocks it's pretty simple. Characters 0x00-0x7f are emitted as is. There are also fixed-length and variable-length blocks embedded in the stream that you have to deal with. (These correspond to the WordPerfect markup, à la "Reveal Codes").

    Fixed length blocks are introduced with a marker byte in the range of 0xc0-0xcf. There follows a fixed amount of characters, followed by a matching 0xc0-0xcf.

    Variable-length blocks are a bit trickier. They are introduced with a marker byte in the range of 0xb0-0xbf. The first word after the marker byte encodes the length of the block. At the end of the block you also have a matching 0xb0-0xbf marker byte.

    With a hex-viewer you should be able to puzzle it out. It's funny how time changes things. The format used to be documented in several places on the Web. Right now I can't find a single useful/complete definition any more. Hmm, nor do I have my old source code to this application anymore either. Hmmmm.