RTF文件,如何解析。
RTF文件,如何解析?指点方法
{\rtf1\ansi\ansicpg936\deff0\deflang1033\deflangfe2052{\fonttbl{\f0\fnil\fcharset134 \'cb\'ce\'cc\'e5;}{\f1\fswiss\fcharset0 Arial;}}
{\colortbl ;\red255\green0\blue0;\red255\green255\blue0;\red0\green128\blue0;\red0\green0\blue0;}
\viewkind4\uc1\pard\cf1\lang2052\f0\fs24\'d1\'fd\'b8\'e7\'a3\'ac\cf2\highlight3\lang0\f1\fs20\u35874?\u35874?\u24744?\u65281?\cf4\par
}
#include <ComCtrls.hpp>
String __fastcall RtfToTxt(TForm *frm, String strRtf)
{
TRichEdit *re = new TRichEdit(frm);
TMemoryStream *ms = new TMemoryStream;
re->Parent = frm;
re->PlainText = false;
ms->Size = strRtf.Length();
ms->Write(strRtf.c_str(), strRtf.Length());
ms->Position = 0;
re->Lines->LoadFromStream(ms);
re->PlainText = true;
String str = re->Lines->Text;
delete ms;
delete re;
return str;
}
void __fastcall TForm1::Button1Click(TObject *Sender)
{
Caption = RtfToTxt(this, Memo1->Lines->Text);
}