trichview.com

trichview.support




Re: unicode save and load


Return to index


Author

Message

Sergey Tkachenko

Posted: 01/26/2005 23:03:58


1) Set Unicode property to True for all TextStyles in TRVStyle

2) Set RichViewEdit1.RTFReadProperties.UnicodeMode = rvruOnlyUnicode

3) Some methods cannot be used, if the document is in Unicode.

- Add, AddFmt, AddNL, AddNLTag, AddTextBlockNL (use AddNLATag or AddNLWTag

instead)

- AddTextNL (use AddTextNLA or AddTextNLW instead);

- SetItemText (use SetItemTextA or SetItemTextW instead)

- SetItemTextEd (use SetItemTextEdA or SetItemTextEdW instead)

- SetCurrentItemText (use SetCurrentItemTextA or SetCurrentItemTextW

instead)

4) Existing non-Unicode RVF documents must be converted to Unicode by

calling

ConvertToUnicode after loading them (see below).

It safe to call this procedure for Unicode documents - it will do nothing.


procedure ConvertRVToUnicode(RVData: TCustomRVData);

var i,r,c, StyleNo: Integer;

    table: TRVTableItemInfo;

begin

  for i := 0 to RVData.ItemCount-1 do begin

    StyleNo := RVData.GetItemStyle(i);

    if StyleNo>=0 then begin

      if not RVData.GetRVStyle.TextStyles[StyleNo].Unicode then begin

        RVData.SetItemText(i, RVU_GetRawUnicode(RVData.GetItemTextW(i)));

        Include(RVData.GetItem(i).ItemOptions, rvioUnicode);

      end;

      end

    else if RVData.GetItemStyle(i)=rvsTable then begin

      table := TRVTableItemInfo(RVData.GetItem(i));

      for r := 0 to table.Rows.Count-1 do

        for c := 0 to table.Rows[r].Count-1 do

          if table.Cells[r,c]<>nil then

            ConvertRVToUnicode(table.Cells[r,c].GetRVData);

    end;

  end;

end;


procedure ConvertToUnicode(rv: TCustomRichView);

var i: Integer;

begin

  ConvertRVToUnicode(rv.RVData);

  for i := 0 to rv.Style.TextStyles.Count-1 do

    rv.Style.TextStyles[i].Unicode := True;

end;




> The editor I use is Richview Actions test editor.

> I do not use a special unicode type. I save the file as unicode txt after

I

> inserted several unicode symbols from Insert Symbol (Font:Courier

> New,Character Table:Unicode).

> The content of the file is okay as binary.

> In the same way, when I read the unicode txt file from File/Open menu, the

> coming file is converted to ANSI just as you tell.

> However MS Word can read the file correctly.

> What shall I do to read the file not converted to ANSI?

>

> When I save the file in RVF format, everything is okay.

>

> You asked me if I have specified the unicode txt style or not. How can I

> specify it?

> I send you an example file in order to make clear the problem.

>

>

> "Sergey Tkachenko" <[email protected]> wrote in message

> news:[email protected]...

> > Do you specify Unicode text style for loading this file?

> > If not, the text will be converted to ANSI

> >

> >

> > > Hello,

> > >

> > > I have registered version 1.9.2.2.

> > > I save a unicode text (for example \x2500 unicode char(-)) txt file.

But

> I

> > > load this file I get  |  char.

> > > If I save same file RVF format everything ok.

> > > Thanks

> > >

> > >

> >

> >

>

>

>





Powered by ABC Amber Outlook Express Converter