RTF files

This is a discussion on RTF files within the Windows Programming forums, part of the Platform Specific Boards category; Hi, I'm writing a program to sort text files alphabetically in two levels. I got it working with *.txt files, ...

  1. #1
    The larch
    Join Date
    May 2006
    Posts
    3,573

    RTF files

    Hi,
    I'm writing a program to sort text files alphabetically in two levels. I got it working with *.txt files, but I'd like to do the same with *.rtf files.
    Do you know, how I could get the plain text from the rich text format (preferably line by line).

    The program basically uses an entry class like that:

    Code:
    class Entry
    {
        string entry;     //original line of text
        string entry_c; /*lowercase line of text, with some special 
    characters trimmed from beginning*/
        vector<Subentry> sub; //similar class of subentries
        //...
        bool operator < (const Entry& a)
        {return this->entry_c < a.entry_c;} /*for sort algorithm, sort vector of Entry's 
    by trimmed, lowercase lines*/
    }
    With a rtf file I could use the same classes, except string entry would have the line in rich text format and entry_c would have the (trimmed) plain text. Is it doable and does it make sense?

  2. #2
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,506
    Sure, RTF is just tagged text after all.
    It should be pretty easy to parse once you've read the specs for the file format.
    http://www.google.co.uk/search?q=rtf+file+format
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  3. #3
    The larch
    Join Date
    May 2006
    Posts
    3,573
    Well, I've written a parser for RTF in another language. I thought there would just be a Windows API for that.

    Oh well...

  4. #4
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,506
    I'm sure there is, maybe the more experienced windows programmers can help.

    Moved to windows board.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  5. #5
    erstwhile
    Join Date
    Jan 2002
    Posts
    2,227
    Do you know, how I could get the plain text from the rich text format (preferably line by line).
    One possibility might be to use a richedit control and send it an EM_GETLINE message, once you've streamed the rtf text into it.
    CProgramming FAQ
    Caution: this person may be a carrier of the misinformation virus.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Ressources files
    By mikahell in forum Windows Programming
    Replies: 4
    Last Post: 06-19-2006, 06:50 AM
  2. add source files to embedded VC 4.0
    By George2 in forum C++ Programming
    Replies: 4
    Last Post: 06-13-2006, 03:28 AM
  3. *.cpp and *.h files understanding
    By ElastoManiac in forum C++ Programming
    Replies: 4
    Last Post: 06-11-2006, 04:45 AM
  4. Linking header files, Source files and main program(Accel. C++)
    By Daniel Primed in forum C++ Programming
    Replies: 3
    Last Post: 01-17-2006, 10:46 AM
  5. Multiple Cpp Files
    By w4ck0z in forum C++ Programming
    Replies: 5
    Last Post: 11-14-2005, 01:41 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21