Može da se konvertuje tekst fajl u rtf. Uzme se rtf kao taj što je poslao X files, odvoji "zaglavlje" od kraja a u sredinu se ubaci tekst. Tekst se konvertuje u kodove, gde je malo a: \'e0, malo b je: \'e1. Ostali kodovi su u nastavku a \par je za novi red. Ništa drugo nije potrebno za konvertovanje i tako se može dobiti ćirilični rtf koji se učitava.
Na
codesearch mogu da se nađu slični primeri:
Code:
//---------------------------------------------------------------------------
//This function writes the complex number into the RichEdit
void ComplexToRTF(Func32::Complex C, TRichEdit *RichEdit)
{
const TData &Data = Form1->Data;
//Create rtf string to everything to become bold
//Font f0: MS Sans Serif
//Font f1: Symbol
AnsiString Str = "{\\rtf1\\ansi\\deff0{\\fonttbl{\\f0\\fswiss\\fprq2\\fcharset0 MS Sans Serif;}{\\f1\\froman\\fprq2\\fcharset2 Symbol;}}\n\\f0\\fs18 ";
switch(Data.Property.ComplexFormat)
{
case cfReal:
//Check for an imaginary part
if(std::abs(C.imag()) < MIN_ZERO)
Str += RoundToStr(C.real(), Data);
break;
case cfRectangular:
{
//Round numbers to chosen number of decimals
AnsiString Real = RoundToStr(C.real(), Data);
AnsiString Imag = RoundToStr(std::abs(C.imag()), Data);
if(Imag == "0" || std::abs(C.imag()) < MIN_ZERO) //(-1.50)^2 = 2.25+2.4395E-19i
Str += Real;
else //If there is a imaginary part
{
if(Real != "0")
Str += Real + (C.imag() < 0 ? '-' : '+');
//Add imaginary part to string
if(Imag != "1")
Str += Imag;
Str += "\\b i";
}
break;
}
case cfPolar: //Polar format
//The complex number 0 does not have an angle
if(C.real() == 0 && C.imag() == 0)
{
Str += '0';
break;
}
Str += RoundToStr(abs(C), Data); //Get numeric value as a string
//Add angle symbol to text in Symbol font
Str += "\\f1\\fs20 \xD0\\f0\\fs18 ";
if(Data.Axes.Trigonometry == Func32::Degree)
//Add degree symbol, if angle is in degree
Str += RoundToStr(std::arg(C) * 180 / M_PI, Data) + "\\f1\\fs20 \xB0";
else
Str += RoundToStr(arg(C), Data);
}
Str += "\n}";
//Use stream to put data into RichEdit
std::auto_ptr<TStringStream> Stream(new TStringStream(Str));
RichEdit->Lines->LoadFromStream(Stream.get());
}
Ovaj primer ne radi baš to što se traži, samo je primer za formiranje rtf fajla.