trichview.com

trichview.support




Re: Unicode problem with chinese character


Return to index


Author

Message

Sergey Tkachenko

Posted: 06/28/2005 19:12:08


Asian languages are supported only via Unicode.

You will be able to load and save DBCS files, but internal text must be

Unicode.


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;




> Try to open the Chinese Content.rvf in TRichView Editor demo. While

resizing

> the form width, rve will be resize too, when you resizing, you will see

some

> of the character changed to some unreadable chinese character for example

?

> or A will occur.

>

> Any clue??

>

>

>





Powered by ABC Amber Outlook Express Converter