Home > 2. Windows Programming, Native Code > RTF to HTML converter in C++

RTF to HTML converter in C++

Download source code (9KB)

Nearly, I used RichEditCtrl in a MFC project, and I want to take formatted RTF text in that control to display on a HTML control. I searched through CodeGuru and found this one. It’s a nice job, but it leaks 2 things:

  • Doesn’t work well with unicode. In fact, it can’t recognize unicode characters.
  • A minor error when calculating font size.

As you maybe known, in RTF format, an unicode character is encoded in two ways:

  • \u6884: 6884 is character code (in decimal) of this letter (it’s “Ấ“) .
  • \’1EA4: 1EA4 is character code (in hexadecimal) of this letter (it’s “Ấ“) .

So I slightly modified Daniel Beutler’s code in order to work around these problems. You can found my code in the following functions: CRTF_HTMLConverter::R2H_CreateHTMLElements and Util::StringToLong.

Advertisements
  1. 05/12/2011 at 5:18 PM

    I am continually looking online for articles that can help me. Thank you!

  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: