Page 1 of 1

How to support unicode for multiline text

Posted: Mon Dec 04, 2006 1:16 am
by uniandy
Hi Sergey-

Do you have any updates for the exampe:
http://www.trichview.com/support/files/script2.zip

in the main unit, you said:
- supporting Unicode text (some modifications in InsertMultilineText are Not implemented

I tried your example, and it really cannot support multi text unicode, this is the snapshot:

Image

the A part is the original 2-line text and the B part is the result, I tried to solve the problem but haven't find any solution so far, do you have any better solutions on how to change InsertMultilineText menthod to support unicode for multiline text?

Posted: Mon Dec 04, 2006 3:34 am
by uniandy
procedure InsertMultilineText(RVData: TCustomRVData; var ItemNo, Pos: Integer; const Value: String);
var
item: TRVTextItemInfo;
s1, s2: String;
sl: TStringList;
i: Integer;
begin
if Value='' then exit;
s1 := RVData.GetItemTextA(ItemNo);
s2 := Copy(s1, Pos, Length(s1));
s1 := Copy(s1, 1, Pos-1);
sl := TStringList.Create;
sl.Text := Value;
// workaround - TStringList ignores the last cr lf
if (Length(Value)>1) and (Value[Length(Value)-1]=#13) and (Value[Length(Value)]=#10) then
sl.Add('');
// end of workaround
if sl.Count=1 then begin // if it's a single line, then do this
RVData.SetItemTextA(ItemNo, s1+Value+s2);
sl.Free;
inc(Pos, Length(Value)-1);
exit; // exit when this is done
end;
RVData.SetItemTextA(ItemNo, s1+sl[0]);

// for multi-line, maybe this is whether the non-unicode is caused
for i := 1 to sl.Count-1 do begin
item := RichViewTextItemClass.Create(RVData);
s1 := sl;
if i=sl.Count-1 then s1 := s1+s2;
item.StyleNo := RVData.GetItemStyle(ItemNo);
item.ParaNo := RVData.GetItemPara(ItemNo);
item.Inserting(RVData, s1, False);
RVData.Items.InsertObject(ItemNo+i, s1, item);
item.Inserted(RVData, ItemNo+i);
end;

ItemNo := ItemNo+sl.Count-1;
Pos := Length(sl[sl.Count-1])+1;
sl.Free;
end;

Posted: Wed Dec 13, 2006 11:54 pm
by uniandy
Hi,Sergey-

Can you help me to solve this problem? I cannot find any solution on this...

Many thanks

Posted: Thu Dec 14, 2006 1:15 pm
by Sergey Tkachenko
I'll modify this example later this week.

Posted: Tue Feb 13, 2007 7:26 am
by uniandy
Ha, it's been a long time from last visit from this community. it's so happy that I can visit this site again use a Germany web agent. :D

Posted: Tue Feb 13, 2007 7:27 am
by uniandy
Hi,Sergey-

Any updates for this functionality?

best wishes

Posted: Wed Feb 14, 2007 5:06 pm
by Sergey Tkachenko
Oops, sorry.
Done. Not only modifications to support Unicode in this demo, but also a completely Unicode version.
See here: http://www.trichview.com/forums/viewtopic.php?t=9#5883

Posted: Fri Feb 16, 2007 4:49 am
by uniandy
Sergey-

Thanks a lot, you are great and cool!

This is perfect !!!